|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionThere are many methodologies surrounding design patterns and standards available in reference to the software development life cycle. Each needs to address the following issues: standardization, reuse-ability, and scalability. The standardization aspect consists of coding standards, naming conventions, comments, use of interfaces, etc. Reuse-ability looks at the extendability, and flexibility to run as a component model, or wrap-able an n-tiered approach. Scalability encapsulates the emphases on robust coding, performance, and data usage and transfers and finally security. For sure there are many decisions involved in designing and developing an application, even the simplest applications should require ample amount of design work before implementation takes place. In this articles, I will take an easy and simple business requirement and go through the process of the design and implementation where I will try to emphasis on standardization, reuse-ability, and scalability. Background
Name Value Storage ProjectUser RequirementsIn this example, the business user requires a program be built to store Name Value Pairs such as FirstName = Yang where FirstName = The Name value must can only be alpha numeric values, and spaces around the equal sign should be ignored. The storage needs to be xml based and the GUI must be simple and user friendly. DesignUse CaseThe User Requirement in this case is simple, and straightforward. Without meeting with the clients to gather more information, we can now deduce a useful List of Actions that can be performed, we can also draw up the high level interactions between Users and the Software. At this point, we can also create a list of processes the application's must haves, and should haves that would increase the reuse-ability, and extendibility. A Use Case diagram can be put together to illustrate this.
Even though we only have one User and some very simple Use Cases, the process can quickly grow and become more complex. By analyzing the Use Cases, we can minimize the risks involve in under taking feature changes as well as development time. Process DiagramThe next step is to introduce some process diagrams into the design. A good starting point is to take each Use Case and extrapolate an Business Process out of it. Again, a good design is dictated by the robustness on validations, extendability and error handling. Error handling and validations ties in hand and to hand. The result of specific business rules validations should generate specific exceptions or result that is controlled within the application. Lets take a look at a very simple Process of Creating a Name Value Pair.
This process is a simple and involves particular layers of business operation. The segregation of the business layers will give clues to the implementation phase, and reduce the amount of effort in actual project design. It is important to focus on the way entities in the process connect since this ultimately reflects the performance and will be utilized for security on calculating attack surfaces. Class Diagram
The Key to a robust and scalable application lies in its core design model. Since most applications deal with information, it is critical to develop a model that will capture all the properties of the required information as well as the interactions and relationships between them. The more you understand about what it is you are trying to capture, the better the model will be, and the more robust and scalable the application will be. Many times during this phase, you will be faced to challenge the business users on why a particular decisions about the types of information are captured. A robust object oriented model sometimes does not follow a particular business model, since the business requirements usually apply to a very scope centric and project centric collection of data. Due to this face, our model may lack growth potentials and key elements that allow future advancements and scalability. It is crucial to challenge the Business Users whenever possible to increase the scope or alter it to enable the project to reach its potentials. By following this methodology, we can deliver more with less time for the first phase, and for future phases as well. Usage of InterfacesBelow is the Class Diagram for the Name Value Storage Project. Instead of simply using a Hash table or Dictionary as my implementation, I've Started off the project by introducing an Business Logic Interface. using System;
using NameValueLib.BLL;
namespace NameValueLib
{
/// <summary>
/// Name value collection is used to manage a list of Name/Value pairs
/// </summary>
public interface INameValueCollection :
System.Collections.Generic.IList<NameValuePair>
{
/// <summary>
/// Raised on Adding new NameValuePair to the List
/// </summary>
event NameValueHandler InsertNameValuePair;
/// <summary>
/// Raised on Deleting NameValuePair from the list
/// </summary>
event NameValueHandler RemoveNameValuePair;
/// <summary>
/// Add a new Name value pair into the list given a single patterned input in the format of [Name][delimiter][Value]
/// </summary>
/// <param name="NameValueString"></param>
void Add(string NameValueString);
/// <summary>
/// Removes all the name value pairs
/// </summary>
void Remove(NameValuePair[] nameValuePairs);
/// <summary>
/// Sort the list by Name ascendingly
/// </summary>
void SortByName();
/// <summary>
/// Sort the list by Value ascendingly
/// </summary>
void SortByValue();
/// <summary>
/// Sort the Name Value collection by a sort by and order
/// </summary>
void Sort(NameValueComparer.SortByType sortBy, bool ascending);
/// <summary>
/// Get the XML output of the list
/// </summary>
/// <returns></returns>
string GetXML();
/// <summary>
/// Save the List to an XML File
/// </summary>
/// <param name="FileName"></param>
void Save(string FileName);
}
}
If you look at the Use Case, you will notice that there are a lot of similarities. By segregating the implementation and the abstract prototype, having this interface, allows room for extendability and to create standardization. Depending on the size and User desires, I can wish to implement this interface a number of ways either with a N-Tier ArchitectureBy Adapting an N-Tiered approach, we enough the application to cross domains, reused, pluggable into any type of application weather its web or windows or even services, we've allow it be registered in the GAC, and even for COM+. We've also opened new door for more secure abilities while not increasing the attack surface of the core functionalities. N-Tiered Architecture render many benefits that out weights the disadvantages. It is now an industry standard and is the bridge to the next generation applications such as SAAS. The Project is split up into 2 Tiers, the Business Logic Layer and the Presentation Layer done in Windows Forms. I can easily implement a web version of even a console version for the presentation layer. A point to make about standardization. Standardization enables the project to be understood by peers even by yourself in the future if you needed to make changes. Coding standards and naming conventions can be critical in minimizing the amount of find need in searching and filtering. It is an good idea to develop a standard project layout (using folders) as well as class layout (using namespaces). This not only help us developers it can sometimes help CLR to more efficiently execute grouped code. ValidationA robust business layer should contain solid validations of input variables. You should never trust the client no mater how secure the presentation layer is. The pattern I used in the project uses the .NET Exception framework. To efficiently utilize the .NET exceptions framework, ..
public void Add(string NameValueString, string Delimiter)
{
string Errors;
// pre: validate
if (!NameValueValidator.DefaultValidator.ValidateNameValueInput(NameValueString, Delimiter, out Errors))
throw new NameValueException(Errors);
try
{
// find delimiter position
int delPos = NameValueString.IndexOf(Delimiter);
// create new Name Value Pair
this.Add(new NameValuePair(NameValueString.Substring(0, delPos).Trim(),
NameValueString.Substring(delPos+Delimiter.Length).Trim(), Delimiter));
}
catch (NameValueException nex)
{
throw nex;
}
catch (Exception ex)
{
throw new NameValueException("Error Parsing Name Value Input.", ex);
}
}
.. Events and DelegatesThe usage of events and delegates provides an way to intercept application triggers, aswell as a way to efficiently extend business logic. In this project, I've created a delegate to handle generic Events such as <<>> public delegate void NameValueHandler(object sender, NameValuePair NameValuePair);
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
|
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 24 Apr 2008 Editor: |
Copyright 2008 by Yang Yu Everything else Copyright © CodeProject, 1999-2009 Web20 | Advertise on the Code Project |