What is the essence of good software design

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: What is the essence of good software design

Post by josh »

pytrin wrote:Does this improve their design by default? to me that's a somewhat twisted view to look at things.
It improved one aspect of it. Theyre the twisted ones not me :mrgreen:
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: What is the essence of good software design

Post by Eran »

Open source software is notorious for focusing on the developer or tech savvy and yet it is somehow remarmably successful in the end user arena, how? Maybe because it's free and people will put up with a lot more when something is free, such as poor support, bad performance, buggy software, insecurities, etc.
I found this very insightful. From my vantage point, wordpress and phpBB were the first (or amongst the first) open-source packages to offer the kind of full featured solution that they do, and people used them cause were free and available. With time the surrounding plug-in support (ie, community) grew to such a scale that competing products (better designed?) stood little chance without some serious marketing push, which is not something an OS package usually has.
It further reinforces my point that the perceived quality of the source code is much less important user, domain, and now market factors. It starts to look more and more like relentless pursuit of the user is key to success.
But I wasn't talking about software success or the importance of design to the user, was I? I was talking about the characteristics of design that make it beneficial for the development efforts, since that is its intended customers. Software design is meant to serve developers, not end users. For the same reason graphical designers use grids, typographic rules etc, we use design to improve the development process so we could more easily deliver to our users what they want.

I don't understand how it keeps going back to the users - users affect requirements which in turn affect design. But the design is there to ease the implementation of the requirements - it is not aware of the users per-se. Many superficially different features can be solved with the same design, and one feature can be solved using many designs. Suppose a project comes to completion and the requirements are met. The quality of design can be measured not by the success of the product - but by how easily were the requirements met, how easy it to change it now or extend it, how easy is it to optimize it and so forth. I think we all agreed that the success of a software product is not related at all to the code that drives it, so there is no reason to keep going back to that.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: What is the essence of good software design

Post by Christopher »

pytrin wrote:I found this very insightful. ... I don't understand how it keeps going back to the users ...
I found it the opposite of insightful. And honestly I think there is little point in responding because we look at software development from completely different contexts. The result is just frustration...
(#10850)
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: What is the essence of good software design

Post by Eran »

Imagine my frustration - when I started this thread I thought I could discuss the principles of PHP design with some talented and experienced developers. It seemed to be the right place, under "Theory and design" - but it seems here you can only discuss the effects of design on users and on the success of software products.

Thanks again for your input. I meant no offense in any of my posts, hope you took it at face value.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: What is the essence of good software design

Post by josh »

pytrin wrote:Many superficially different features can be solved with the same design, and one feature can be solved using many designs. Suppose a project comes to completion and the requirements are met. The quality of design can be measured not by the success of the product - but by how easily were the requirements met, how easy it to change it now or extend it, how easy is it to optimize it and so forth. I think we all agreed that the success of a software product is not related at all to the code that drives it, so there is no reason to keep going back to that.
While I agree with this paragraph somewhat, for instance yes: you can meet the same set of requirements with many designs. However, my argument is simply that the whichever design more closely resembles the reality context of it's users has the better design. For instance the requirement might be that you need to be able to assign people to houses in a publicing housing management system. One design could be that you assign the people to the chimney. Your customer would probably call you a smartass when you told him that you met all requirements because anything that belongs to the chimney also belongs to the house.

Then let's say your competitor modeled the house tenants reality from a different perspective. Since he understood the problem, his software assigns people to the rooms of the house instead of the first part of the house that popped into his head [the chimeny]. Now lets say this software takes 5 seconds longer to run and and the light switches of the house emit sparks :D I would rather live in the house with the sparking light switches, knowing I could replace those light switches for a nominal cost, then to be stuck in my Chimney knowing I have worse problems then a malfunctioning light switch.

Likewise the materials the chimney, walls, etc.. was made out of would be a part of the design ( as a metaphor of your coding metrics ), but if my house designer put the toilet next to the fridge, I couldn't give 2 craps about the chimney, frankly I'd be pretty ticked off at the house designer.

So I guess what I'm saying is don't stuff your user's into their chimney :crazy: Changing around the chimeny interface would be a larger refactor then the lightswitch ( in my metaphor ). You might argue your design is better because you made the chimeny replaceable in case the user wants to change the chimney around, but then again your house didn't have rooms.

( I'm using you / the competitor just to make it easier to follow, not saying you make that big of design mistakes, but we all make some and they add up over time to irritate users )
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: What is the essence of good software design

Post by alex.barylski »

Imagine my frustration - when I started this thread I thought I could discuss the principles of PHP design with some talented and experienced developers. It seemed to be the right place, under "Theory and design" - but it seems here you can only discuss the effects of design on users and on the success of software products.
Agreed. I think it's funny how each of us are disscussing different phases of the SDLC and trying to come to a common agreement. :P

I'm like you, I'm not disputing the fact that user experience is everything in the success of a project, but it does depend on you define success.

If you develop for educational purposes, then the cleanest design is probably what dictates "success" - not pleasing your end users. However, in thie case, you as the developer are the end user, so "in essence" that project would be successful too. :P

What I find most interesting is arborint's insistence that user experience is everything, when he is typically the first to judge anyone's "design" when it's proposed on this forum. Either he has experienced a traumatic fall and forgot, what it is we do here, or he has had a change of heart and wants to see crappy software like WordPress propagate the Internet. LOL

Useful or not is subjective and highly debatable. I use WordPress for my own blog and all I have experienced is problem after problem but like I said, it's free and I can't really complain so I deal with it. If I were paying, absolutely they'd hear from me.
One design could be that you assign the people to the chimney. Your customer would probably call you a smartass when you told him that you met all requirements because anything that belongs to the chimeny also belongs to the house
You keep stressing "reality" and yet counter argue with that?

How stupid do you think I am? (don't answer that)

What makes you think I'm going to "design" software in such a way it's useless to my users? And MOST importantly...why can't I satisfy *all* of my user requirements/specifications AND develop rock solid software? With less bugs, more secure, better performance, more standardization, etc, etc???

Cheers,
Alex
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: What is the essence of good software design

Post by josh »

PCSpectra wrote:What I find most interesting is arborint's insistence that user experience is everything, when he is typically the first to judge anyone's "design" when it's proposed on this forum.
What I find most interesting is how personal this has come. We must take these issues pretty seriously :D
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: What is the essence of good software design

Post by Eran »

While I agree with this paragraph somewhat, for instance yes: you can meet the same set of requirements with many designs. However, my argument is simply that the whichever design more closely resembles the reality context of it's users has the better design. For instance the requirement might be that you need to be able to assign people to houses in a publicing housing management system. One design could be that you assign the people to the chimney. Your customer would probably call you a smartass when you told him that you met all requirements because anything that belongs to the chimney also belongs to the house.
I understand what you are saying. Misinterpretation of requirements is something that happens in every project, and certainly you could say the requirements were not met. However in the examples you suggested, it seems more like an implementation issue - with the right design it should be easy to correct, and with a bad design it would mean rewriting significant portions of the code. Those kind of issues test the quality of the design in my opinion.

It was actually Spectra who suggested metrics as validation of a good design. I suggested less measurable qualities, such as code maintainability, extendability, readability etc. Those are obviously subjective, but I think there are several practices and solutions than have been shown to increase those qualities.

Continuing with your house metaphor (doesn't everybody loves metaphors? ;) ), I consider the blueprint of the house, the laying of foundations, the considerations of what land to build on, wind directions etc, as the "design" of the house as it correlates with code design. Suppose the chimney was modular and could be moved around, you could say the design is good for allowing the chimney to be replaced on a whim.

By the way, I used to live in an apartment where the toilets were next to the kitchen.. and I had no chimney, so go figure :P
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: What is the essence of good software design

Post by alex.barylski »

Likewise the materials the chimney, walls, etc.. was made out of would be a part of the design ( as a metaphor of your coding metrics ), but if my house designer put the toilet next to the fridge, I couldn't give 2 craps about the chimney, frankly I'd be pretty ticked off at the house designer.
There are some houses with toilets by the fridge...their called low rental bachelour pads...I've lived in one. :P

Again, subjective. You'd be terribly <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> if the designer or contractors installed insulation with absestos or they failed to install fire alarms or they use termite infested wood.

The point is...some design choices are not that cheap and easy to fix and some are critical mistakes.

Let me now draw on the analogy I often use (because I'm a huge aviation nutt and wannbe pilot). If the designer of the MD-80 had anticipated the failure of a single jack screw in the horizontal stablizer would result in catastrophic events and *corrected* the problem at design time as opposed to later having to retro-fit all MD-80's, some 88 lives would have been spared:

http://www.aviationweek.com/aw/generic/ ... w%20Issues

I know failure in my software will not likely result in anyone's untimely death but I take what I do very seriously. While no one will lose a life, they might certainly lose some data (which can be extremely valuable and hard to replace). In fact I would wager most computer users would value their data more important then their software.

So while you might be able to go back and retrofit your apartment and fix those blinking light switches, if the house burns down and everything is lost, your user would probably prefer a safer, more fire resistent apartment with effective ergonomic design.
What I find most interesting is how personal this has come. We must take these issues pretty seriously
I don't take it personally...but I do take it seriously :)

Cheers,
Alex
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: What is the essence of good software design

Post by Eran »

the failure of a single jack screw in the horizontal stablizer would result in catastrophic events
Something you don't hear everyday
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: What is the essence of good software design

Post by alex.barylski »

I suggested less measurable qualities, such as code maintainability, extendability, readability etc. Those are obviously subjective, but I think there are several practices and solutions than have been shown to increase those qualities.
I'm always interested in hearing/learning about these but to avoid unnessecary argument I will not argue I will only ask, like what?

Can you give some examples of your own best practices, or personal experiences?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: What is the essence of good software design

Post by josh »

pytrin wrote: I consider the blueprint of the house, the laying of foundations, the considerations of what land to build on, wind directions etc, as the "design" of the house as it correlates with code design. Suppose the chimney was modular and could be moved around, you could say the design is good for allowing the chimney to be replaced on a whim.
This is true, I'm just saying you can spend all your effort considering wind directions and overlook something as obvious as the toilet/fridge issue. In this sense they all contribute to the design.
pytrin wrote:So while you might be able to go back and retrofit your apartment and fix those blinking light switches, if the house burns down and everything is lost, your user would probably prefer a safer, more fire resistent apartment with effective ergonomic design.
What if you were building a training house for the fire dept. and a requirement was for it to burn down. In this sense the different context takes the whole design direction and flips it around. That's all I'm saying
I'm a huge aviation nutt and wannbe pilot.
Me too, you ever flown? The new G1000 all glass cockpits are great ( great design :P )
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: What is the essence of good software design

Post by Eran »

Can you give some examples of your own best practices, or personal experiences?
When I design, I'm concerned with A. Maintainability and B. Development speed. I want to be able to develop more features in less time, while writing code that is easy to maintain / change / extend / optimize (all of those I consider maintainability), not only for me but for other developers that might be working on the same source code. In order to achieve this I employ the following practices (some of those might sound very basic, but I'm not making any assumptions):

1. Coding standards - I think it's very important to pick standards you are comfortable with and stick with them almost religiously. Coding standards help normalize the structure of code, increase readability and maintain consistency throughout. I use the PEAR/ZF coding standards - http://framework.zend.com/manual/en/cod ... style.html. Commenting is a part of that, and I use the phpDoc block comment style.

2. Scoping and modularization - Separating different parts of the application into separate "modules" and making sure each runs in a separate, clean scope is very important for maintainability. For this purpose I model everything in classes (I consider OO to be the best scoping mechanism PHP has to offer), separate functionality as much as possible to different methods, and make sure the absolute minimum runs in the root application scope.

3. Code reuse - as much as possible, reusable code should be encapsulated and de-coupled. I use inheritance where needed, composition where possible in order to put together functionality from reusable building blocks. This affects both maintainability and development speed - if you can control repeating logic from one place you can make changes much easier, if you can reuse logic - you save development efforts.

4. Framework(s) - A natural lead off from code reuse. When the most generic, repeatable logic can be separated from domain implementation, it should be put together in a framework. When those reusable logic blocks can be reused in other projects, they save a ton of time in development. I'm not promoting any particular framework (I use ZF by the way ;) ), using an OS one or a commercial one or a home brewed one doesn't matter - as long as it saves development time. From personal experience I found that using more mature frameworks that many developers test everyday in practice is quite beneficial and that's my reason for using Zend's.

5. Tests - (Unit) Tests help raise the quality of code by validating certain aspects of it repeatedly and quickly. Testable code usually exudes other desirable qualities - such as high decoupling and better interface. Tests help protect against change and help the refactoring process (which is another important part of development).

6. Design patterns - Using widely accepted good (best?) solutions when appropriate instead of trying to roll your own each time in my experience is very beneficial. Design patterns are reusable (hence I should probably have this solution in my framework ;) ), increase de-coupling (mostly) and usually increase maintainability (if applied correctly). I'm not talking implementations of design patterns, but the pattern itself to solve common problems.

7. Domain modeling - I usually start by modeling the structure of the storage system (if one is present). In most projects, this means I start with my database modeling and later model my domain classes after that structure. I find this usually helps flesh out the relationships inherent in the domain and most often some refactoring as those relationships reveal themselves.

8. Refactoring - I refactor my code constantly to help it increase in the qualities I mentioned - readability, reusability, maintainability etc.

There are probably some things I forgot, but those are my main practices as I design and implement my code.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: What is the essence of good software design

Post by alex.barylski »

Something you don't hear everyday
Not in a developer forum, nope. :lol:

I'm torn to which industry I appreciate more...software or aviation. I love flying I think the engineering is nothing short of amazing. Watching the wing of an aircraft begin generating lift and taking flight...hearing the sound of an turbine engine spool up....the feeling of power as you get kicked back into your seat as you accelerate from zero to 200kts in less than a few seconds...

It literally brings tears to my eyes...as does beautiful software or an injured kitten...haha
What if you were building a training house for the fire dept. and a requirement was for it to burn down. In this sense the different context takes the whole design direction and flips it around. That's all I'm saying
That was me that said that BTW. Obviously requirements are taken into consideration. :P

Houses designed for fire fighters...are rarely "designed" to burn to the ground...only the contents are...usually when firefighters burn a building to nothing it's a dilapidated house condemmed by the city and donated to the fire department as a training excersize.

Standardized fire fighter training facilities are actually quite fire retardant -- I live about 5 kilometers from one so I see it go up in flames all the time and it's been standing for well over 20 years. :P Just saying. Haha.
Me too, you ever flown? The new G1000 all glass cockpits are great ( great design )
pytrin wrote: I consider the blueprint of the house, the laying of foundations, the considerations of what land to build on, wind directions etc, as the "design" of the house as it correlates with code design. Suppose the chimney was modular and could be moved around, you could say the design is good for allowing the chimney to be replaced on a whim.
This is true, I'm just saying you can spend all your effort considering wind directions and overlook something as obvious as the toilet/fridge issue. In this sense they all contribute to the design.
pytrin wrote:So while you might be able to go back and retrofit your apartment and fix those blinking light switches, if the house burns down and everything is lost, your user would probably prefer a safer, more fire resistent apartment with effective ergonomic design.
What if you were building a training house for the fire dept. and a requirement was for it to burn down. In this sense the different context takes the whole design direction and flips it around. That's all I'm saying
I'm a huge aviation nutt and wannbe pilot.
Me too, you ever flown? The new G1000 all glass cockpits are great ( great design :P )
My Dad works for Air Canada so I've flown many times in my life. I was in Air Cadets as a kid as well so I've been in planes of all sizes, piloted a few, etc. I went for a familirization flight a while back...it was a very moving experience for me.

Now pilots share a camaraderie...in WWII it was not uncommon for Pilots to let the enemy off the hook when it was clear they were out of ammunition (between the Germans and Allies anyways) or having trouble maintaining flight. I watch DogFights on History all the time...it's crazy some of the stories I've heard of the guys waving to each other depiste being mortal enemies...
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: What is the essence of good software design

Post by alex.barylski »

There are probably some things I forgot, but those are my main practices as I design and implement my code.
While I agree with everything...it's hard to disagree with anything as the statements are to general. I know I said I wouldn't argue but without debating, how does one learn from others?

I could say I keep my code clean...but what that means exactly is debatable.

However if I say, I keep my code clean and on average my files are less than 100 lines and classes never exceed 10 methods. While it's not a gaurantee, it does give some idea as to the amount of atomicity of my classes and modules.

Do you keep more than one class per file? How many comments/line of SLOC does your codebase have?

These are tangible metrics which while not perfect, certainly are more indicative of "clean" design if we all agree that "clean" means:

1. Easy to read code
2. Modular code
3. Atomic classes
4. Simplicity

And so on and so forth.

Cheers,
Alex
Post Reply