Section 2.1. Modular Architecture

Divide and Conquer > Modular Architecture

Chapter 2. Divide and Conquer

Divide and conquer is a well-known method for delivering complex projects by breaking the whole project into smaller tasks until those tasks are simple enough to be solved directly.

Divide and conquer also has the advantage of being a natural target for parallelization. This means that different people can solve different tasks at the same time, shortening the overall development time. This can be a great advantage particularly if your team is following the waterfall model[*] of software development.

[*] The waterfall model is a sequential software development model in which development is seen as a sequential list of activities: requirements specification, design, implementation, testing, deployment, and maintenance. This model, although created in the 1970s, is still very popular among development teams.

NOTE

Always divide tasks according to their functional domain first, and only then within the same domain. It will help you assign tasks more easily.

To begin with, after you decompose your large project into smaller tasks, you need to be able to implement those tasks separately. That's a lot easier if you adopt a modular architecture from the start.

2.1. Modular Architecture

One of the principles of large-scale web development is to use a modular architecture on your projects. Modularity can best be achieved by following the object-oriented programming (OOP) paradigm, which provides some important characteristics of software design, as you can see here:


Inheritance

A way to create new classes using previously defined classes. The new classes inherit attributes and operations of the pre-existing classes. This approach highly incentivizes the reuse of existing code.[dagger]

[dagger] There is a well-known statement that disputes this advantage: "Because inheritance exposes a subclass to details of its parent's implementation, it's often said that 'inheritance breaks encapsulation'" (Gang of Four 1995:19).


Modularity

The measure of the way an application is divided into components, or modules. On a modular architecture, you should create interfaces between modules, as a way to increase control over the data flow.


Polymorphism

Using a single definition with distinct types of data. In OOP, polymorphism refers to the ability to use objects of different types to respond to methods with the same name, each one with a specific behavior according to its type.


Encapsulation

Also known as information hiding,[double dagger] this is a method that enables developers to hide information about business logic from the implementation. This abstraction is usually done through the use of interfaces so that any change to the underlying code is not transported into code that uses it.

[double dagger] Some authors make distinctions between encapsulation and information hiding. See Rogers, P., "Encapsulation is not information hiding," JavaWorld, May 2001 (http://www.javaworld.com/javaworld/jw-05-2001/jw-0518-encapsulation.html), via Wikipedia.

PHP implements all these features, making it possible to develop software following the OOP paradigm. This is no longer a territory available only to other so-called object-oriented programming languages.

The best way to have access to a modular architecture is to use a framework on your projects. There are many PHP frameworks out there, but PEAR is by far the oldest and the most qualified. PEAR has more than 400 submitted and tested packages that you can use right away. In the next section, we present other characteristics that make PEAR such a good framework.

 

 



PHP and Smarty on Large-Scale Web Development
PHP and Smarty on Large-Scale Web Development
ISBN: 047008023X
EAN: N/A
Year: 2007
Pages: 20
BUY ON AMAZON

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net