Tuesday, August 3, 2010

Assingment: Case Study 11

If you have used any UI application, you would have seen that one control depends on the selection of the other. So let us say that you have three combo boxes Country, state and city on a webpage or a dialog. Country and state acts as filter for the city combo box. If the Country combo is changed the state and City combo has to be repopulated. How would you model this behavior? One possible solution is that City combo can register a listener for change in selection with Country and State Combo, what problems do you foresee? You can think of having 10 such controls that depend on each other to come up with a solution.

Assignment: case Study 10

You have been requested to write interrupt handler mechanism for a new OS. OS can allow for multiple handlers for same interrupt even though the processor may allow for just one. How would you model the interrupt hander mechanism to allow for multiple handlers for the interrupt? Don’t focus on efficiency, just think of multiple ways to achieve it.

Assignment:Case Study 9

A dialog is a kind of a window and so are text boxes, labels, listboxes and buttons. Each window can have child windows, child window means that life time of the child window is dependent on the parent window and child window can be placed anywhere on the parent window. Assume that a dialog has few controls like listbox, etc on it, you need to depict this relationship using…my symbols(or UML)…on a piece of paper
–If I want to go over all the controls and blink them, suggest me a way to do it. Blink can be achieved by just show-hide-show but think about how to iterate over the controls, if you are not using STL or any other standard container classes

Monday, August 2, 2010

Assignment: Case Study 8

We have an inhouse C++ SDK that exposes fixed interface to read and write JPEG, TIFF & PDF files. There is a sniffer class that tells us which type of file type it is and based on that we create the instance of FileFormat (JPPEG, TIFF, PDF) class using a factory. The problem is that for PNG we have taken open source implementation and it doesn’t conform to our existing C++ interface. Please suggest what you believe is the best approach.

Assignment : Case Study 7

We have a neatly written application and all important classes are derived from one Abstract class and uses Factory method for creation. We are witnessing some performance issues so we need to find the time to execute the important functions of these classes and also log the in and out parameter. The log of parameters and time taken to execute the calls is independent, can be switched on and off separately. I suggested that we can change all these 20 classes with some #def code and put the relevant code. My Architect says that he doesn’t want to build unnecessary dependencies in main code and these can be selectively turned on customer side to fine tune the performance. Please suggest.

Sunday, August 1, 2010

Assignment: Case Study 6

We are using a third party image library and we wrapped it up in a clean c++ interface (One Abstrsact class with 15 functions) but during testing found that it is not thread safe and it is used at a lot of places. So my architect suggested that let us spawn an exe for each thread that wants to use it and kill the exe when the thread dies. He suggested that exe can take an XML that describes the operation that I want to invoke and the parameters, with the in and out image path. The problem is that I will have to change my code at lot places to achieve it and I don’t have a lot of time to make this change and test my module. What do you suggest?

Tuesday, July 27, 2010

Assignment:Case Study 5

EFI Send me Frameworks has a very interesting problem to solve. The UI of the application can be implemented for multiple platforms to name a few browser, wxWidget, MFC, Xwindows, etc. The application has 10 dialogs and each dialog has fixed number of controls on it. The controls can be like labels, text boxes, list boxes, buttons,etc. The idea is that anyone should be able to implement UI in their choice of technology. The application decides what control will be placed where and application also wants that some of the predefined events to be generated in response to the user input. Each Dialog is rendered based on the application intent, it means that if User Login Dialog needs to be rendered than application wants two labels, two text boxes and two buttons with Cancel and OK on it to be displayed. On click of Ok and Cancel the relevant events needs to be generated.

You need to design the application interface to support such a behavior. Don’t focus on events and layouts. What are the things you would consider when designing such a system? What all behavior you want to abstract? For people from .Net background, please focus on Web and Desktop solution.

The focus should be on creation and class hierarchy, don’t get lost with the function names and their signature.

Thursday, July 22, 2010

Assignment Day 3

Case Study 3

•A curve is defined by some finite points, each point is represented by an x and y value. Assume that the curve has about 1000 points
User wants to find points that meet the following criteria
–x> 2y
–y = x
– Y > x^2
–X is even
–Y is odd
–X= some value
–Y= some value
–X = some value + some other value * 5
In future we can have many more such operations to be performed on the curve.
Come up with the class diagrams or class declarations
-------------------------
Case Study 4

•I am working on an Imposition application where I have to provide some default layouts to the user that will place images on a page. The default layouts can be like lay all the images horizontally, vertically or in a table like format with n number of rows and m number of column or in a diagonal or around the perimeter of the page. Please come up with classes and their interaction. Assume that our graphics team is very creative and will come up with more of such layouts in future. Focus on Page and layouts.

Wednesday, July 21, 2010

Assignment Day 2

Case Study 1
•Rajneesh has approached you for help. He has one global object of each class A,B,C,D & E. He needs to ensure that they are created in the order they are listed and destroyed in the reverse order. He also shares with you that they have to be thread safe. Please suggest him.
-----------------------------------
* Think about the problems associated with Singleton and how can you resolve them...
* If the Manager class in your Code is a singleton evaluate and share the repercurssions of that decision. Does it in any way inhibit the future design changes? Under what circumstances will it become a bottleneck.?
-----------------------------------
Case Study 2
•Problem: Design a plugin framework such that anyone can write a reusable component that can be accessed by your application. To keep it simple let us only talk about database plugins that allow information to be written in various formats, like XML, SQL lite, Oracle, File, ODBC driver, OLE DB/ADO, basically anything that can persist the information. The focus should be how to instantiate such plugins.
----------------------------------
•Double Check Locking singleton (For Further Reading)

Sunday, July 18, 2010

Assignment Day 1:Sniffing

  1. The code has a lot of similar ifs at many places
  2. To fix a bug you have to apply the same fix at many places
  3. Your code has a lot ifs doing enum/type/string comparison to decide the function to be called for a particular object
  4. It is difficult to find out which function is called when
  5. Many classes in the code has more than 20 functions
  6. The number of classes with similar names is endless in your project
  7. Get/Set functions are virtual
  8. You can’t understand the purpose of the class by looking at its header file
  9. This is derived from that and that is derived from that and that is derived from that, so this and that have a ‘is a relationship’…didn’t get it…let us start again…
  10. Derived class doesn’t override even one virtual function defined in the base class
  11. Almost every new feature needs changes in at least 10% of the files in the project
  12. You can copy and paste the code Reviewer of the code always says, I am looking at this code for the first time…
  13. The number of Abstract classes…are you not able to find any?