How to balance brevity and abstraction

Abstraction is the key to php programming. You must carefully choose the degree of abstraction you need. Newbie programmers, with their enthusiasm, often create more abstraction than is really useful. A sign of this is if you are creating classes that don't really contain any code and really don't do anything except serve to abstract something. This attraction is understandable, but the value of code brevity has to be weighed against the value of abstraction. Every now and then, we see a mistake made by enthusiastic idealists: at the start of the project, many classes are defined, which seems wonderfully abstract, and one can expect that they will handle any eventuality that may arise. As the project progresses and fatigue sets in, the code itself becomes messy. Function bodies are getting longer than they should be. Empty classes are a burden to document, which is ignored when under pressure. The end result would have been better if the energy expended on abstraction had been expended on keeping things short and simple. It's a form of speculative programming.

There is a certain dogma associated with useful techniques like information concealment and object-oriented programming that are sometimes taken too far. These techniques allow you to code in an abstract way and anticipate changes. However, I personally think you shouldn't be producing a lot of speculative code. For example, it is an accepted style to hide an integer variable on an object behind mutators and accessors, so that the variable itself is not exposed, but only the interface to access it. This allows the implementation of this variable to be changed without affecting the calling code, and may be appropriate for a library programmer who needs to release a very stable API. But I don't think the benefit of this outweighs the cost of verbosity when my team has the calling code and can therefore re-code the caller as easily as the callee. Four or five more lines of code is a heavy burden to pay for this hypothetical profit.

Portability poses a similar problem. Does the code need to be portable to another computer, compiler, application system, or platform, or just easily portable? I think a short, easy-to-carry, non-portable piece of code is better than a long, portable code. It's relatively easy and certainly a good idea to confine non-portable code to a specific location, such as a class that performs database queries specific to a given DBMS.

The Different Roles of a PHP Development Team: What to Expect When Working with One

If you're a business owner who is new to the world of the php development team, you may be wondering what to expect when working with a team of developers. In this blog post, we will outline the different roles that are typically found in a PHP development team. This will give you a better understanding of the process and help make the experience smoother for both you and your development team. The first role we will discuss is the project manager. The project manager is responsible for the [...]

The Pros and Cons of Programming Languages: Which One Is Right for You?

There are a lot of programming languages pros and cons to choose from, and it can be difficult to decide which one is right for you. In this blog post, we will discuss the pros and cons of some of the most popular programming languages. We will also give you some advice on which language you should learn depending on your goals and experience level. So, whether you are a beginner or an experienced programmer, read on to find out which programming language is right for you! Pros and Cons of [...]

How to Learn PHP Programming: The Basic Steps

PHP is a programming language that is used to create dynamic web pages. It is one of the most popular programming languages in use today, and it is estimated that over 80% of all websites are created using PHP. If you want to learn how to program in PHP, then you are in luck! In this blog post, we will outline the basic steps that you need to take in order to become a PHP programmer. The first step is to choose a programming editor. This is the program that you will use to write your PHP code. (programming php) [...]

M'abonner aux flux %KW% sur %NDD%.