Hi NH,
I read as much as
I can about designing systems (and I cant really find any decent books) I
dont have anyone to discuss the best approach or what would be best
practice.
You're attitude is commendable. More time spent up front in learning how to
properly design applications, and more time spent in the design process,
ultimately mean much time saved over the long haul, both in current
development, and in future maintenance and upgrade.
Here's an excellent (and free) resource for all types of subject matter in
this domain:
http://msdn.microsoft.com/practices/
I notice that you seem to be thinking a bit too specifically when it comes
to the design of your current project, and about design in general. For
example, take the following question:
How can I handle this business logic in
asp.net, create some classes and use datasets so the application itself
handles the logic? And then use SP's for purely retrieving data?
My personal approach is to not think too specifically about a problem, but
to think about the principles involved. There are many good approaches to
design and architecture, and quite a few patterns out there, but the good
ones are all based upon the same principles, and grow out of them.
In the above question, you ask about a specific technology (ASP.Net), and 2
specific tools (DataSets and Stored Procedures). This is a fairly common
mistake, and I've been guilty of it myself, which is why I'm sharing what
I've learned with you. By being so specific, you limit yourself to thinking
only about a particular environment (such as ASP.Net) and the
characteristics of the specific tools. You ask whether Stored Procedures
should be used for only a specific purpose. A better way to state the
question might be:
How should business logic be handled in an application, and what sort of
business classes might help to connect the data in the database with the
user interface in such a way as to minimize the amount of change needed when
a change is necessary in either the interface or the data? To what extent
should any database member modify data, handle data validation and protect
the integrity of the data in the database?
Now, that's just an example, but notice that I avoid specifics. By doing so,
I force myself to think about the whys and wherefores of the parts of the
application, and free myself to think of more alternative solutions.
ASP.Net and, for example, Windows Forms, have quite a lot in common, and
quite a lot of principle is shared by both. One may apply the same
principles to both environments. Every application centers around data of
some sort. In every applicatioon, data is stored somewhere, whether
externally or internally. Every application manipulates that data and/or
changes it. Every application has an interface, whether it is a user
interface or a programming interface. Every application has business logic
which enforces a set of rules concerning what should be done with the data,
and how it should be done.
So, in effect, every application has data, process, and interface. Every
application has a set of requirements, a set of needs that it is designed to
fulfill. Beyond that, things become increasingly specific. But I find it
useful to start at the most common level and work my way up (down?) to the
specifics.
Now, for maintenance and extensibility, some separation is in order. By
loosely coupling these components, we eliminate dependencies, making it
easier to islolate and change any individual part without having to rebuild
the whole app at one time. The wheels of a vehicle are not welded to the
axle; they are bolted. One can swap out a wheel without having to swap out
the axle. By limiting wheels to a certain range of sizes, we gain the
ability to use the same wheel on multiple vehicles.
So, we generally start by separating out the 3 basic components of an app,
data, process, and interface, and then begin to subdivy the components of
each one until we have a nice, modular, extensible architecture. Once you
have isolated each component, you can begin to think about the requirements,
and what areas of responsibility each component needs to fulfill. At that
point, you begin to get a little more specific.
Remember that the requirements you are given may be more specific than is
useful as well. Try to think of the requirements in a more abstract way. For
example, you mentioned that your next project is a "forecasting system." You
may have been given a set of requirements such as "We need to be able to
gather weather information from the National Weather Service for the greater
metropolitan area, and provide forecasts on our web site." But you need to
break that requirement down. It may (and probably will) change at some point
in the future. You might rephrase the requirement as "We need to be able to
gather weather-related information from the best weather sources available,
and provide that information in a variety of user and programming
interfaces, for a variety of purposes." Now, when you design the solution,
it will be extensible, and if you design your components well enough,
isolating functionality into various categories that translate into
namespaces, classes, etc., you will be able to extend, re-use, and maintain
a variety of apps with different combinations of those components.
If you can train yourself to think in this sort of way, and practice it, you
will become a more powerful programmer over time. It's not just a matter of
reading and studying, although those are indispensible. It is also a matter
of practice.
Best of luck to you!
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
We got a sick zebra a hat,
you ultimate tuna.