Nevyn's Blog

Tuesday, 5 August 2008

OOP criticisms

As this blog grows, I intend to take the novice web developer from their procedural roots, and lead them by example to setup their own clustered, scalable web server platform for their own applications.

A lot of programming books only give simple examples, and avoid object oriented designs. Whilst the adage 'Never explain beyond what is absolutely necessary to the understanding of a topic' holds, the lack of context sometimes leave you wondering how to include examples in your own site.

Now, clustered servers might not be of use to you. You might not even use MySQL, PHP or Apache, in the end. You may not like the idea of Smarty templates. Last but not least, you may well struggle to get to grips with OOP.

Well it's not for everybody. So here is some criticism of OOP to bring balance to this thread, and reduce any perceived bias. Feel free to read it and decide for yourself if OOP is not for you: http://www.geocities.com/tablizer/oopbad.htm

Now, I have seen a post on http://www.devx.com/opinion/Article/26776 denouncing OOP, claiming that procedural code-reuse can be acheived by copy-n-paste. Thats code duplication, not code reuse! but I agree with the author in some respects, anything that is over-administered, over-complicated and over-engineered can make for unwanted bloat, and sometimes quick-n-dirty hacks will suffice.

Even with relatively little experience of OOP myself, I see the benefits of using it, and begining to see my projects in a more abstract level. You dont need to abandon your procedural roots - but to allow your skills to develop, embed procedures in classes, and they become universally available (reusable) units that save you from reinventing the wheel continually.

Heck, getting my head around it whilst using a relatively easy language (php) has resulted in being able to follow more complicated c++ code - perhaps not completely, but certainly I can get more of a feel. You can then go into even greater depth and understand how the two languages differ, and grasp concepts like structs, references, pointers and variable type / casting. Well, thats all for now, I feel like some programming... =)

Labels: , , ,

Tuesday, 22 July 2008

Apache, MySQL and PHP (AMP Servers)

What is an AMP server? (also known as LAMP, WAMP, XAMPP...)
As the title suggests, Apache, MySQL and PHP (or sometimes PERL) running together make an AMP server. LAMP suggests that they are running on a Linux platform, WAMP denotes a Windows server and XAMPP is a package that can be used to setup an AMP server on Apple's OS X.

Apache is a web server
MySQL is a database engine
PHP & PERL are scripting languages typically used on web servers.

Whilst PERL (Practical Extraction and Reporting Language) is a very mature and powerful language, novice programmers may find it difficult to start with. PHP on the other hand, was intentionally written with the novice developer in mind, deliberately making it easy for novices to create web pages and applications. It has also matured, and supports Object Oriented Programming concepts, such as classes, Inheritance and so on, has a clean looking syntax resembling C/C++ (simmilar comments, and bracing styles).

It does upset some OO purists as in keeping with PHP's 'lets keep things simple for the webbie' approach meant it has done things in a way that might not be considered 'true'. For example, it is not a strongly typed language, and it recently changed its default behaviour for passing by value and passing by reference.

If none of that made any sense to you, don't worry!! You could start out with PHP writing things in a procedural style, and find that as your skills develop, you will discover that PHP can grow with you, and you can begin to adopt the OOP style.
(Object Oriented Programming, vs Procedural style.)

Now this post is deliberately short, and meant as an introduction to new users. There are other alternative databases, webservers, and scripting languages, and I am not suggesting they cannot be used instead. In fact, the concepts which apply to an AMP server could equally apply to IIS, PoorMan, Lighthttpd, PostgreSQL, Oracle, SQL server, and so on - feel free to experiment and find what works best for you! =)

The reason for covering AMP servers is that I use them myself, and they form the fundamental basis from which I create my sites and applications. When I cover the topics in more detail, I will most likely use AMP projects in the examples. By keeping to a common platform in this way, I only need to explain the basics once - and can focus on writing about the concepts, instead of the differences between all the competing technologies.

Labels: , , , , , , , , , , ,