Please help me to design a Profile comparison

Hi,

I have a class named ProfileData. earlier we used to serialize and deserialize each ProfileData object in a separate file. Now we have a feature where we need to compare two ProfileData objects and store the comparison in another file.

Here profile data consists of profiling info for an application. i.e stats on cpu time for methods classes, package etc.

ProfileData has an array ProfileSample, ProfileSample have an array of StackEntry, each StackEntry has a FunctionData class. Function data has info abt name, package, class, line etc.

Noe can somebody help me in implementing a suitable design for ProfileComparison class which should contain the ProfileData objects compared and data rekated to comparison result. I want to reuse the existing code to the max. Which design pattern would be suitable to this or any better idea to acheive this

Comments

  • edited November -1
    I think you need one of the structural patterns. I think the one that would fit very well would be the flyweight pattern:
    - ProfileData: the flyweight
    - ProfileComparison: the concrete flyweight storing only the changes.
  • edited November -1
    Hi
    i think instead of creating a new cass for comparision, its better to create a new method in the profile date class itsefl which does the comparision and stores the result.This way it will be encapsulated better.If the comparision code is put in the new class , the classes become interdependent and if there is any change in the profile data class , the same should be communicated to the new class too making them tightly coupled. In the former case objects are more independent of each other and are more loosely coupled.Loosely coupled is when the objects in your application each have a specific job to do and they do only that job.This way the functionality of your app is spread out over lots of well defined objects , which each do a single task really well.Its also called SRP(Single responsibility principle).

    I also though about cubic's idea of applying the FLyweight pattern, but could not proceed thinking what should be the key used by flyweight factory and client to create the concreteflyweight, though the intrinsic property is the result of comparision. Also we have to pass the extrincic property which could be the profile data array, but that does seem to fit here.

    Regards
    krishna
    wrte me: [email protected]