Home
About
Search
🌐
English Română
  • When the optimization should take place

    Citește postarea în română

    Aug 3, 2010
    Share on:

    There are whole books about optimization, but few mention when is the right moment for the optimization to take place.

    There are several perspectives with fundamental differences:

    • during development
    • at the end of the development cycle
    • never

    What is the correct answer? In fact there are only less correct or inadequate.

    During development

    This answer has the most potential to be wrong.

    Even though is the most common method and it shouldn’t be interpreted as being wrong, it has the potential to cause issues.

    When it may cause issues? When instead of optimization, micro-optimization is used in excess.

    Micro-optimization can come in many shapes, depending on how the project is developed. Some write “bulk” code or procedural code, others use frameworks and ORMs. When your deviating from the general rule of writing code to do optimization you should think about the consequences. It will be harder for the next guy that looks at your code to understand what’s going on, and if you make a rule out of that, with time the project will become indecipherable.

    For instance if your using ORM and you start typing SQL you are already losing the purpose of the ORM. In ROM there are several steps for each interrogation:

    Building the objectual interrogation -> Parse to SQL -> Execute interrogation -> Parse result -> Loading the resulting objects

    vs.

    Building the SQL interrogation -> Execute interrogation -> Parse result

    The steps may varies depending on the implementation.

    A lot of the times the second approach looks simpler and is faster for sure. But why use the first approach? For the architectural advantages! You can set triggers when accessing or setting the properties for instance.

    A mature developer is the one that writes “readable” code, not just optimum.

    At the end of the developing cycle

    The advantage is that there are no architectural compromises during development.

    This is usual the best method, because you have the finished product, developed without compromise and you can see which points should be optimized. When you have all the components is much simpler to reorganize them then during the development when changes may appear, which in turn can generate for instance code redundancy.

    The disadvantage is that at the end is sometimes difficult to find the week points of the application.

    Never

    First of all let’s make it clear, I mean “serious” projects.

    There is a general rule that’s saying “hardware is cheap, programmers are expensive”. More broadly this means that a lot of the times is easier to scale an application using hardware then doing major compromises in the code.

    A lot of companies and projects support this perspective. Correctly applied this principle has the advantage of having a well organized code, easy to read and with few hacks.

    The advantage is at development, few hacks make a project more organized (in theory) and easier to extend.

    Unfortunately looks like there is also a different interpretation: “if must work, it doesn’t have to be perfect”. Where can this lead to? Basically is the best excuse for dirty code.

    The major difference is that you never optimize, and the code will look just as bad as when you do excessive micro-optimization.

    Conclusion

    In general, project that use excessively micro-optimization, have a great potential to be often rewritten, either partially of full, because there is another rule that says “rather then repair, a lot of the times is easier to rewrite”. Unfortunately projects with bad written code suffer the same fate.

    A major disadvantage to bad code is that it slows the development cycle, in other words minor tasks tend to last longer and longer to be accomplished.

    Projects don’t have to be always optimized. But when we have to do that, compromises regarding the architecture must be at minimum.

Claudiu Perșoiu

Programming, technoloy and more
Read More

Recent Posts

  • Moving away from Wordpress
  • Custom path for Composer cache
  • Magento2 and the ugly truth
  • A bit of PHP, Go, FFI and holiday spirit
  • How to make use of the Xiaomi Air Conditioning Companion in Home Assistant in only 20 easy steps!
  • How I use Magento2 on my local with Docker and Docker Compose
  • About passion, programming and heating systems
  • The Books for Zend Certified Engineer 2017

PHP 49 MISCELLANEOUS 44 JAVASCRIPT 13 MAGENTO 7 MYSQL 7 BROWSERS 6 DESIGN-PATTERNS 5 LINUX-UNIX 2 WEB-STUFF 2 GO 1

PHP 35 JAVASCRIPT 14 PHP5.3 11 MAGENTO 7 PHP6 7 MYSQL 6 PHP5.4 6 ZCE 6 CERTIFICARE 5 CERTIFICATION 5 CLOSURES 4 DESIGN-PATTERNS 4 HACK 4 ANDROID 3
3D1 ADOBE-AIR2 ANDROID3 ANONYMOUS-FUNCTIONS3 BOOK1 BROWSER2 CARTE1 CERTIFICARE5 CERTIFICATION5 CERTIFIED1 CERTIFIED-DEVELOPER1 CHALLENGE1 CHM1 CLASS1 CLI2 CLOSURES4 CODE-QUALITY1 CODEIGNITER3 COLLECTIONS1 COMPOSER1 CSS1 DEBUG1 DESIGN-PATTERNS4 DEVELOPER1 DEVELOPMENT-TIME1 DOCKER1 DOCKER-COMPOSE1 DOUGLAS-CROCKFORD2 ELEPHPANT2 FACEBOOK2 FFI1 FINALLY1 FIREFOX3 GAMES1 GENERATOR1 GO1 GOOGLE1 GOOGLE-CHROME1 GOOGLE-MAPS1 HACK4 HOMEASSISTANT1 HTML2 HTML-HELP-WORKSHOP1 HTML51 HUG1 HUGO1 INFORMATION_SCHEMA1 INI1 INTERNET-EXPLORER3 IPV41 IPV61 ITERATOR2 JAVASCRIPT14 JQUERY1 LAMBDA1 LINUX1 MAGENTO7 MAGENTO22 MAP1 MINESWEEPER1 MOTIVATION1 MYSQL6 NGINX1 NODE.JS2 NOSQL1 OBSERVER3 OBSERVER-PATTERN1 OOP1 OPERA1 OPTIMIZATION1 ORACLE1 PAGESPEED1 PAIR1 PARSE_INI_FILE1 PHONEGAP2 PHP35 PHP-ELEPHANT2 PHP-FOR-ANDROID1 PHP-GTK1 PHP42 PHP53 PHP5.311 PHP5.46 PHP5.53 PHP5.61 PHP67 PHP7.41 PROGRAMMING1 REVIEW1 ROMANIAN-STEMMER2 SAFARY1 SCALAR-TYPE-HINTING1 SCHEME1 SET1 SHOPPING-CART-PRICE-RULE1 SINGLETON1 SOAP1 SPL2 SQLITE1 SSH1 STACK-TRACE1 STDERR1 STDIN1 STDOUT1 SUN1 SYMFONY2 TEST-TO-SPEECH1 TITANIUM2 TRAITS1 TTS1 UBUNTU1 UNICODE2 UTF-82 VECTOR1 WEBKIT1 WINBINDER1 WINDOWS1 WORDPRESS1 YAHOO3 YAHOO-MAPS1 YAHOO-OPEN-HACK1 YSLOW1 YUI1 ZCE6 ZCE5.31 ZEND3 ZEND-FRAMEWORK3
[A~Z][0~9]

Copyright © 2008 - 2021 CLAUDIU PERȘOIU'S BLOG. All Rights Reserved