Tips and Tricks in a world of Mix

Archive for the ‘Best Practice’ Category


Product Management – what is it? (resources)

  • What is Product Management


Product management is an organizational life-cycle function within a company dealing with the planning, forecasting, and production, or marketing of a product or products at all stages of the product life-cycle. Similarly,product life-cycle management (PLM) integrates people, data, processes and business systems.


  • The Simple Rule for Feature Prioritization


Prioritizing features without a product strategy is like mapping a route without a destination.

When you prioritize features, ask yourself:

  • Are you prioritizing features without a solid strategy and prioritization criteria?
  • Are you only listening to the loudest stakeholder, biggest customer, or squeaky wheel?
  • Are you just chasing after the features of the competition (feature parity)?
  • Are you trying to chase the latest trend in your industry?

If you answer yes to any of the above questions, then your prioritization will not only be difficult, but it’ll be highly ineffective.

So here is the simple rule: Your feature prioritization should flow from your overall product strategy.

Your company’s strategy will inform your high-level roadmap, which tells you what type of functionality you need to build in the short- and mid-term, to satisfy your customers needs as well as other internal company needs.


  •  How to use data to make decisions.


You Can Use Data to Make Better Roadmap Decisions

Product managers may think that unsolicited customer feedback only helps them to understand the vocal minority (the customers who voluntarily share their thoughts and ideas). However, carefully collected feedback combined with other data provides an objective look at every customer, making it an an excellent way to learn more about who your customers actually are and how they’re using your product. Knowledge is power, right?

..product managers can make more well-rounded product roadmaps by relying on a combination of feedback and data; customer feedback is fuel for ideas, while data is fuel for decisions. For example, when deciding between updating an old feature or adding a new one based on several customer suggestions, you can look at the lifetime value (LTV) of the customers who’ve requested the update and the LTV of customers who’ve asked for a new feature to determine which initiative would be most valuable to your company.

While analysis paralysis is real, it’s easily avoidable when you keep in mind what the goals of this data analysis are, decide what the information threshold for a decision is, and always remember that done is better than perfect!



  • How do you know if a product is well designed



flexibile for change,

fast performance,



strategize  adding features


Encrypt–Decrypt connectionString

public static void Encrypt(){

           Configuration objConfiguration = null;

           if(HttpContext.Current!=null)        //if we are in web application of some sort

               objConfiguration = WebConfigurationManager.OpenWebConfiguration (“~”);

           else       ///if not web

                objConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

           ConfigurationSection objSection = “connectionStrings”;

           //if encrypted already don’t do it again

           if(objSection!=null && !objSection.SectionInformation.IsProtected){


                           objSection.SectionInformation.ForseSave = true;





public static void Encrypt(){

                     Configuration objConfiguration = null;

                       if(HttpContext.Current!=null) //if we are in web application of some sort

                                   objConfiguration = WebConfigurationManager.OpenWebConfiguration (“~”);

                       else ///if not web

                                    objConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

                      ConfigurationSection objSection = “connectionStrings”;

                           //if encrypted then decrypt

                            if(objSection!=null && !objSection.SectionInformation.IsProtected){


  //objConfiguration.Save();  – you can save the change but it will reset all the global data of your application in iis (relevant to comment it for web applications,can stay on in others)



New Vs Override

The new modifier instructs the compiler to use your implementation instead of the base class implementation. Any code that is not referencing your class but the base class will use the base class implementation.

The override modifier may be used on virtual methods and must be used on abstract methods. This indicates for the compiler to use the last defined implementation of a method. Even if the method is called on a reference to the base class it will use the implementation overriding it.

Design Patterns Quick Reference

Heap vs. Stack

The Stack is responsible of what’s been “called”  ,is self-maintaining, meaning that it basically takes care of its own memory management. First in last out – “FILO” .Stack as a series of boxes stacked one on top of the next.When we’re done with the top box (the method is done executing) we throw it away and proceed to use the stuff in the previous box on the top of the Stack.The Stack is like the Stack of shoe boxes in the closet where we have to take off the top one to get to the one underneath it.

Heap is responsible for keeping track of our objects, its purpose is to hold information so anything in our Heap can be accessed at  any time.there are no constraints as to what can be accessed like in the Stack. we can grab what we need quickly.The Heap,handled by Garbage collection (GC), which deals with how to keep the Heap clean.

We have four main types of things we’ll be putting in the Stack and Heap as our code is executing: Value Types, Reference Types, Pointers, and Instructions.

Value Types: from System.ValueType

bool , byte,char,decimal,double,enum,float, struct..

Reference Types: and inherit from System.Object

class ,interface,delegate,object,string

Pointers: Reference to a Type

We don’t explicitly use Pointers, they are managed by the Common Language Runtime (CLR). A Pointer (or Reference) is different than a Reference Type in that when we say something is a Reference Type, it means we access it through a Pointer.A Pointer is a chunk of space in memory that points to another space in memory.A Pointer takes up space just like any other thing that we’re putting in the Stack and Heap and its value is either a memory address or null.


A Reference Type always goes on the Heap

Value Types and Pointers always go where they were declared.

If the value type is a poco and doesn’t implement some object , than it will enter the Stack.

public int AddFive(int pValue)
               int result;
                result = pValue + 5;
               return result;


But if we are dealing with Pointers  even though the members are primitive types it will be entered into stack and point to the object in the heap.

public class MyInt
         public int MyValue;

public int ReturnValue2()
                MyInt x;
                x.MyValue = 3;
                MyInt y;
                y = x;
                y.MyValue = 4;
               return x.MyValue;




Each local variable is also located in Stack as being sent to the methods.

The methods have a GOTO reference (instructions) which direct them where to return after the method completed.

But if we have a big data primitive member, variable , such as some big struct it can overload the Stack.

The resolution is to use ref

Sending Value Type by ref

public void Go()


         MyStruct x = new MyStruct();

         DoSomething(ref x);


public struct MyStruct


            long a, b, c, d, e, f, g, h, i, j, k, l, m;


public void DoSomething(ref MyStruct pValue)


          // DO SOMETHING HERE….




that way the reference is only entered once in the Stack and if we’d preform that method 1000 times it’ll only add some more pointers to the reference location in the stack.

If our object is big it makes a big difference.

Important – when you are changing the local variable inside the Method where you send value by reference you are actually changing the parameter outside that method also.


Sending Reference Type as parameter

both x and pValue – are set into Stack as a Pointer to Object created in the Heap.

public void Go()


        MyInt x = new MyInt();

       x.MyValue = 2;




public void DoSomething(MyInt pValue)


            pValue.MyValue = 12345;



So to conclusion , the reference(the definition of the object) to the object going to the Stack while the Object itself enters the Heap.

If the initialization of the reference is reinitialized to some other Object than accordingly the reference(hence the Pointer) will point to the new Object that will also be created in the Heap.


For the objects inside the objects to be unique we would want to implement the IClonable interface initializing the inner object each time we need it . Otherwise we can end up pointing out the same object from different parent objects.

We would implement public object Clone() and will get the object returned as MyObjType .

GC –

JIT and CLR  are using the heap – list of used recourses and all that connected to them is mapped to a graph. GC gets the list of "root" object references to keep from just-in-time (JIT) compiler and common language runtime (CLR) and then recursively searches object references to build a graph of what should be kept

Roots consist of:

  • Global/Static pointers. One way to make sure our objects are not garbage collected by keeping a reference to them in a static variable.
  • Pointers on the stack. We don’t want to throw away what our application’s threads still need in order to execute.
  • CPU register pointers. Anything in the managed heap that is pointed to by a memory address in the CPU should be preserved
    Each unneeded object (one that didn’t entered the graph will be erased and the objects will reform a new memory allocation. Each deletion is taking time so it’s better to minimize the amount of created objects.

    There are situations where the GC needs to execute code to clean up non-managed resources such as files, database connections, network connections, etc. One possible way to handle this is through a finalizer.

    class Sample




                             // FINALIZER: CLEAN UP HERE



    What it does – inserts the object to a finalization queue , when GC sees that the object is no longer needed it inserts it into a freachable queue , and only after the finalizer is executed GC will approach to remove it. (at the next generation only) – so actually it’s prolonging the life of the object and maximize the usage of the heap memory , so it’s better to implement the finalizer when and only we really need it.

    A better practice is to be sure to clean up non-managed resources. As you can imagine, it is preferable to explicitly close connections and use the IDisposable interface for cleaning up instead of a finalizer where possible.


    public class ResourceUser : IDisposable


                #region IDisposable Members

               public void Dispose()


                             // CLEAN UP HERE!!!





    If you implemented Dispose and used the using , at the end the Dispose will be executed and GC will know to clean up the unneeded resource.

    public static void DoSomething()


             using (ResourceUser rec = new ResourceUser())


                        // DO SOMETHING

               } // DISPOSE CALLED HERE


    // DON’T ACCESS rec HERE

      Statics and heap overflowed

      1)If we use  a static member inside a static method , we better lock the initialization to prevent access to the same resource by different threads.

      class Counter


      private static int s_Number = 0;

      public static int GetNextNumber()


      lock (typeof(Counter))


      int newNumber = s_Number;

      // DO SOME STUFF

      newNumber += 1;

      s_Number = newNumber;

      return newNumber;




      The best approach with statics will be a singleton pattern

      public class Earth {

                  private static Earth _instance = new Earth();

                  private Earth() { }

                  public static Earth GetInstance() { return _instance; }



      Summary of

      Minify JS on rebuilding the web


      Download JSMIN from

      Instead of opening the WebSite  project , open a WebApp .

      (you can see diff here and here – actually it’s an issue by itself )

      So , on the Property Pages of your WebApp –> goto  build events –>

      build one time script for rebuilding the minified files on each build/rebuild of the project like so :

      "$(ProjectDir)..\jsmin\jsmin" < "$(ProjectDir)\scripts\models\employee.js” > "$(ProjectDir)\scripts\models\employee.min.js"

      (you must adjust the script line accordingly to the position of the JSMIN in your project)

      this will create a few lines of code ..

      then you add instead of the regular employee.js  the newly created employee.min.js to your index.html (start page with references to JavaScript files )

      Also , be careful to add newly created files to the project – Include in project . Check that it also entered into the Source Safe you are using.

      Check in to all and let your team use the minified files on rebuilding the project.

      Managing External Dlls–Make Your Project Portable and Independent

         I think that any programmer have tackled with this problem of missing dlls , or suddenly the dlls are upgraded in the server and you are left with your application to pick up the pieces.

        SO , how can we handle the dlls so that our application won’t be effected by almost anything?

        First of all , it is important to understand that the solution presented here does not cancel the need to install the Framework on the destination machine, meaning that the correct framework must be there always in order for your application to work properly.

        There are few solutions for managing your dlls :

      1)Reference to GAC as usual

      2)Add a folder to specific project with your needed dlls

      3)Add a solution folder to your solution and locate your needed dlls there

      4)Locate your dlls on some Shared Folder in your organization

      5)Build a new Project and insert the dlls there



      In each and every solutions there are Pros and Cons as always :

      method pros cons
      1)Reference to GAC as usual You don’t need to worry about anything, it’s all in the system. If you are using standard Microsoft dlls , even if there will be an upgrade of the dlls version , Microsoft always tries to make it backward compatible – it won’t touch you. If you have some specific dlls , such as Oracle.DataAccess.dll etc. then it can happen that the dll that you have on your terminal , that you develop with is a different version – in this case when you publish your application on the server your application won’t work properly. You’ll get mistakes of bad assembly reference or one of it dependencies.
      2)Add a folder to specific project It’s easy, and whenever you deploy the project you are carrying your dlls with you. If you have a few projects in your solution you can’t use it properly between the projects. You need to keep the location of the folder specific.You could reference the dlls for your current project from a different project folder but when you’ll take the current project as a reference to some third component and then one of the dlls change – you’ll need to recompile all components.
      3)Add a solution folder to your solution and locate your needed dlls there It’s a logical unit just holding the dlls – you are adding a logic meaning composing the dlls by logical themes. When you work with TFS or VSS or any source safe you need to have a physical object of a folder. Another thing – if you have a lot of dlls and you need to drag and drop a whole folder of them into solution folder – you CAN’T, so you’ll have to create every folder by hand inside that solution folder and then import dlls files , folder by folder.
      4)Locate your dlls on some Shared Folder in your organization That’s one of the “good” solutions if you work in organization with LAN , and ability to control permission over domains . You just throw the dlls to some folder and share it with every one you like. If there are multiple users on the same dll , the system creates copies and you won’t get stacked. The down side is handling the source safe again . It creates decentralization of your application. Another thing , in terms of maintenance  you can always forget the specific location of the shared folder or not get enough permissions after system team will perform some update on the server.
      5)Build a new Project and insert the dlls there SO, the great solution yet is to add a new Class Library project , drag and drop the folders you need to take with you and recompile.
      Any component in your solution will reference the  autonomic defined component . You can manage it under your source safe and you can enter it in your deployment package – leaving the hierarchy as predefined at the begging. If the dlls change – all you’ll need to do is to throw the External Dlls project to the server.
      When you create the project and drag and drop the folders you’ll get “Project file must include the .NET Framework assembly ‘WindowsBase, PresentationCore, PresentationFramework’ in the reference list.”  error . It means that your dlls are defined as a Content . You need to go through the folders , choose the dlls(can choose list of them) and in properties change the Build Action to Resource. That’s it.


      So , in this review I’ve shown the best way to make your project portable and independent.

      Now you can enjoy the deployment. Cheers!

      Tag Cloud

      %d bloggers like this: