Search Results

Search found 5 results on 1 pages for 'lortabac'.

Page 1/1 | 1 

  • How to write reusable code in node.js

    - by lortabac
    I am trying to understand how to design node.js applications, but it seems there is something I can't grasp about asynchronous programming. Let's say my application needs to access a database. In a synchronous environment I would implement a data access class with a read() method, returning an associative array. In node.js, because code is executed asynchronously, this method can't return a value, so, after execution, it will have to "do" something as a side effect. It will then contain some code which does something else than just reading data. Let's suppose I want to call this method multiple times, each time with a different success callback. Since the callback is included in the method itself, I can't find a clean way to do this without either duplicating the method or specifying all possible callbacks in a long switch statement. What is the proper way to handle this problem? Am I approaching it the wrong way?

    Read the article

  • How to add a new developer to the team

    - by lortabac
    I run a small company composed of only 2 developers. For one of our clients we are building a very big application, whose development has gone on for 1.5 years. Now this client has found an important sponsorship, and they are organizing some events related to this project, so we have a deadline in 2 months and we can't miss it. We are thinking of adding a new developer to the team, and I am wondering what we can do to help his integration. This is the situation: We are approaching the threshhold of Brooks's law, the point when adding new developers will be counter-productive. The application is relatively well designed, but the implementation is chaotic in some points (especially older code). There are unit tests only for more recent code. When this project started, we didn't have the habit of doing tests. Documentation and comments are incomplete. The application is both large and complex. The client has written down almost every detail about his project, in a very clear and "programmer-friendly" way. Is it a good idea to add a person now? If so, what can we do in order to help the new developer integrate into the team?

    Read the article

  • A solution for a PHP website without a framework

    - by lortabac
    One of our customers asked us to add some dynamic functionality to an existent website, made of several static HTML pages. We normally work with an MVC framework (mostly CodeIgniter), but in this case moving everything to a framework would require too much time. Since it is not a big project, not having the full functionality of a framework is not a problem. But the question is how to keep code clean. The solution I came up with is to divide code in libraries (the application's API) and models. So inside HTML there will only be API calls, and readability will not be sacrificed. I implemented this with a sort of static Registry (sorry if I'm wrong, I am not a design pattern expert): <?php class Custom_framework { //Global database instance private static $db; //Registered models private static $models = array(); //Registered libraries private static $libraries = array(); //Returns a database class instance static public function get_db(){ if(isset(self::$db)){ //If instance exists, returns it return self::$db; } else { //If instance doesn't exists, creates it self::$db = new DB; return self::$db; } } //Returns a model instance static public function get_model($model_name){ if(isset(self::$models[$model_name])){ //If instance exists, returns it return self::$models[$model_name]; } else { //If instance doesn't exists, creates it if(is_file(ROOT_DIR . 'application/models/' . $model_name . '.php')){ include_once ROOT_DIR . 'application/models/' . $model_name . '.php'; self::$models[$model_name] = new $model_name; return self::$models[$model_name]; } else { return FALSE; } } } //Returns a library instance static public function get_library($library_name){ if(isset(self::$libraries[$library_name])){ //If instance exists, returns it return self::$libraries[$library_name]; } else { //If instance doesn't exists, creates it if(is_file(ROOT_DIR . 'application/libraries/' . $library_name . '.php')){ include_once ROOT_DIR . 'application/libraries/' . $library_name . '.php'; self::$libraries[$library_name] = new $library_name; return self::$libraries[$library_name]; } else { return FALSE; } } } } Inside HTML, API methods are accessed like this: <?php echo Custom_framework::get_library('My_library')->my_method(); ?> It looks to me as a practical solution. But I wonder what its drawbacks are, and what the possible alternatives.

    Read the article

  • Is it possible for a good programmer to have never used version control?

    - by lortabac
    I am looking for an expert programmer to help solve a difficult situation. The interviews so far have been surprisingly disappointing. The best candidate so far is a very experienced programmer who has never used version control software. The problem in itself might not be too serious because it is something which can be learned in a short time. But there is a deeper aspect, which worries me: How is it possible to actively develop software for 10-15 years without ever needing version control? Is the fact itself of not looking for a solution to the problem of tracking changes a sign of a wrong attitude to programming?

    Read the article

  • How to write loosely coupled classes in node.js

    - by lortabac
    I am trying to understand how to design node.js applications, but it seems there is something I can't grasp about asynchronous programming. Let's say my application needs to access a database. In a synchronous environment I would implement a data access class with a read() method, returning an associative array. In node.js, because code is executed asynchronously, this method can't return a value, so, after execution, it will have to "do" something as a side effect. It will then contain at least 1 line of extraneous code which has nothing to do with data access. Multiply this for all methods and all classes and you will very soon have an unmanageable "code soup". What is the proper way to handle this problem? Am I approaching it the wrong way?

    Read the article

1