Skip to main content

Posts

Showing posts from 2009

Coupling

A good design thrives for low coupling . The lowest form of coupling is set of disconnected objects, which couldn't form a system. (Since, objects don't interact with each other.) The highest form of coupling is Inheritance, which is one of the pillars of OOPS. The answer for this irony can be "everything is a trade-off in software development". Principles are only guidelines and not rules. An Anology: "Drive Slowly" is a common driving safety guideline. At the slowest speed (0 km/hr), the vehicle doesn't move. Also, people generally wants to buy a vehicle which gives maximum power and speed. Its a guideline to be applied pragmatically. P.S: My another post which shows the legal violation of Command Query Separation Principle .

Distributed Versioning

The version control systems are generally rated as follows based on their usability. Visual Source Safe (Low) CVS SVN Git (High) Visual Source Safe Cons: Visual Source Safe doesn't allow "Concurrent Access". Only one developer can edit a file at a time. Hence, not suitable for a large team with frequent commits. Some times gives weird error messages, making the system unstable. CVS Pro: Allows "Concurrent Access". Multiple developer can edit the file and system has the capability to merge the changes. If there is a conflict, developer is informed to resolve it. Cons: Commits are not atomic. The changes are maintained at the file level and not at the repository level. For eg: if we commit five files at once and want to revoke it, it has to be done individually for each files. SVN Pro: Commits are atomic. Committed files can be revoked together. Repository maintains the check-ins. Cons: Cannot view the history of the file, when not connected to the server.

Review - I

During code reviews, one of the things that is considered is the " Command Query Separation Principle " Violation. Operations should either do something and return nothing or return something and do nothing, NOT both. The common violations are Getter Methods having void as their return types and Setter methods having some return values . Getter Methods having void as their return types. For eg: void GetSalary(Employee emp) { Money salary; //Fetch Salary from some source. emp.Salary = salary; } Generally, these violations can be fixed by renaming the method name to Update. void UpdateSalary(Employee emp); Setter methods having some return values . For eg: bool SetDepartment(Employee emp); Here, it gets tricky. The programmer sets the department inside the method and wants the confirmation by the return value. There are other ways to handle this rather than sending the return value. Having a method HasDepartment() in the Employee, to check whether it has Department. Rai