Click here to Skip to main content
16,020,568 members
Articles / Desktop Programming / WTL

Refactoring: What’s the origin of bad design?

Rate me:
Please Sign up or sign in to vote.
4.00/5 (3 votes)
25 Aug 2010CPOL3 min read 17.3K   7   10
What’s the origin of bad design?

Refactoring is defined as the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure.

Refactoring improves the quality of application design and implementation, but unfortunately the expression “If it is working, don’t change” is many times used to bypass it.

We can find in general three cases concerning refactoring:

  1. Iterative refactoring: Each application can’t be developed perfectly in the first iteration without any feedbacks, even if the team has the best of the architects, designers and developers. The easy way to do refactoring without investing a lot of money and without wasting time is to integrate it in the development process and do it after each iteration.
  2. Refactoring when is necessary: After the application is deployed, there are some feedbacks and bugs, if resolving them take a lot of time or some client needs are very complex to develop and integrate to the existing system, a refactoring can be a good solution to improve the quality of the code base, but in this case it can be very risky and we have to take care to avoid regression in the existing code.
  3. Not refactor: Sometimes even if there are many problems in the existing application, a refactoring is never begun, because the boss does not want to invest in this process, and the support team has to manage the stress generated by all bugs and feedbacks.

Which Factors can Influence the Quality of Design and Implementation?

To avoid investing a lot of money and time when refactoring, the good solution is to design the application well, but there are some traps that can influence the code quality:

No architect and designers in the team

Unfortunately there are some projects initiated with only developers, and no architect is present, the problem is that we can discover this misconduct very early and it can contribute of the project failing.

Prototype

A prototype typically simulates only a few aspects of the features of the eventual program, and may be completely different from the eventual implementation.

Unfortunately many projects are based on the prototype without any review of architecture, design and implementation, and this trap is due to the rapidity of development and the team thinks that’s a good solution to continue with a prototype to gain time.

Frameworks used

Some frameworks provide useful classes but can influence the design too, for example MFC or Qt are intrusive frameworks.

Using some bad designed functionalities of such frameworks can influence to complicate the design of project, let’s take as example the Doc/View design provided by MFC, if a designer chose to consider CDocument as the model as encouraged by the MFC documentation, it will be a bad choice.

The model must be independent of MFC to be used in other contexts easily; however CDocument can be used as controller.

Technology high coupling

Some architects and designers forget the low coupling concept, and propose a high coupled design with the technology or the frameworks used.

For example, if CORBA is used for a distributed system, it must be isolated in the communication level, and all other classes must be CORBA independent.

Unfortunately in some projects, we can find CORBA types used also in the business classes and it complicates the application a lot.

In my opinion, this problem is the most popular and the very dangerous one; it has an enormous impact especially for C++ projects. Indeed currently finding a good C++ developer is not very easy, and finding one who masters many technologies and frameworks become very hard, so creating a high coupling application with technology used implies that all the team must know it, but if the application is low coupled with technology, it will facilitate the human resource department task and they can find easily C++ developers.

Your experience is very interesting to identify the bad design origin, for that you can vote to identify each factor is the most responsible.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions

 
GeneralMy vote of 2 Pin
Aescleal27-Aug-10 20:26
Aescleal27-Aug-10 20:26 
GeneralRe: My vote of 2 Pin
Issam Lahlali28-Aug-10 1:06
Issam Lahlali28-Aug-10 1:06 
GeneralRe: My vote of 2 Pin
Aescleal28-Aug-10 11:25
Aescleal28-Aug-10 11:25 
GeneralRe: My vote of 2 Pin
Issam Lahlali28-Aug-10 11:50
Issam Lahlali28-Aug-10 11:50 
GeneralRe: My vote of 2 Pin
Aescleal28-Aug-10 12:46
Aescleal28-Aug-10 12:46 
I think you and I must come from too completely different development traditions here, your experience is obviously different from mine.

First of all managers can't stop programmer refactoring code. If they want it maintained it'll be refactored. Refactoring is not a separate activity that goes on the project plan - it's an integral part of programming. You don't say to your manager at the start of the day "We're refactoring today..." you say "We're fixing this..." or "We're working on this user story..." and the refactoring happens as part of that activity. If you're a programmer then you'll refactor code.

The cost of refactoring is what happens if you don't do it; your code rots and becomes impossible to modify in a meaningful manner.

As for your last question the last three companies I've worked for over the last 8 years didn't have a separate role for designers and architects. And all the programmers in all three companies practised continual refactoring of the code. It didn't just begin, it happened and was never regarded as a separate cost - it was part of the development ethos of the team.

Cheers,

Ash
GeneralRe: My vote of 2 Pin
Issam Lahlali28-Aug-10 13:01
Issam Lahlali28-Aug-10 13:01 
GeneralRe: My vote of 2 Pin
Aescleal31-Aug-10 7:35
Aescleal31-Aug-10 7:35 
GeneralRe: My vote of 2 Pin
Issam Lahlali31-Aug-10 8:09
Issam Lahlali31-Aug-10 8:09 
GeneralRe: My vote of 2 Pin
Aescleal31-Aug-10 9:35
Aescleal31-Aug-10 9:35 
GeneralRe: My vote of 2 Pin
Issam Lahlali31-Aug-10 9:44
Issam Lahlali31-Aug-10 9:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.