title: What should be the workflow with a git repository?

text: I work on several git repositories though on most not more than 2 people work. Mostly me and my boss. Very often when we work in parallel it happens that "git log" doesn't look so nice because of the merge commits. My boss always complains about that. I really hate that fact because this makes me effectively serialize my work. To prevent these merge commits I must always rebase to the most recent version and go to the other office to make sure that my boss doesn't forget to process the merge requests before committing stuff himself. Even worse he told me that since one week or so he doesn't get email notification for merge request, though I have problems to believe that. Even more worse he now does himself merge request for peer reviewing, elevating the problem more. (The best part is he thinks I always forget to rebase and update on time...) On several occasions I already tried to explain to him that I do everything the way he suggests but he doesn't believe me because he has more experience with git, at least in non-teamwork- environments. I work at this place since 3 months, though I actually do teamwork since a few weeks. I really wished we would use svn because with this workflow in git I waste a lot of my time and I get a headache. In particular we have about 40 repos with modules which are in most cases not longer than 3000 LOC. So when I change something intimate in Repo A I might have to change something in Repo B. If I was deciding, I would put all that stuff into one repo, at least the modules which belong to one group of software. Of course as a new employee you cannot critisize your boss too much or influence him too much. So what is the best way to deal with this problem?


title: Collection vs data structure vs aggregate

text: I know three terms that have to do with storing objects or data. I'm not sure I understand the exact differences between the terms. Please confirm if what I'm about to write is accurate. **A data structure** is a group of data types or objects of the same type, grouped together in some formation. **A collection** is the same as a data structure (I don't mean a Java Collection, I mean a collection in the more general meaning). **An aggregate** is an object containing a collection or data structure, providing an interface to communicate with the inner data structure. For example, the object `someContainer`, which contains an inner `ArrayList`, is an aggregate because it contains a data structure, encapsulates it, and provides an interface to manipulate it. Is all of this accurate?


title: Should we be using git branches or separate repositories?

text: So I have talked my employer into finally jumping on version control...up until now my experience with git has been for personal projects and freelance work where everything is on one server, or small scripts...so, this is a bit above my knowledge. We are going to have 3 web-servers… test, staging, production. We are going to use beanstalk (like github) which will store our repositories remotely and beanstalk will deploy to our servers via sftp (or ssh or whatever we decide). Inside our htdocs folder we have a drupal multi-site install, and we have a bunch of stuff outside of drupal (landing pages, etc...). We would like to have all of our htdocs (except images, file folders, etc...) inside of version control. Should we use one repository with multiple branches? Or 3 separate repositories, each with one branch since they will be deploying to 3 separate servers?


title: Storing a looong lookup table

text: ## Background The product i am working on has a _very_ long lookup-table. the table contains static data and cannot be auto generated. there are about 500 rows and 10 columns. columns have mostly integers and strings. to complicate the matters, there are actually two such tables. every row in table-1 maps to zero-or-more rows in table-2. we use an SQLite database with two tables. the product installer places the SQLite file in the installation directory. the application is written in dot- net and we use ADO to load the data once on startup. **now,**   1. the lookup table grows. in each release a month, we add about 10 new entries   2. existing entries are adjusted. every release we fine tune existing entries. ## The problem a team of (10) developers work on the lookup table. Code goes in the SVN, but the little devil the SQLite does not. this prevents multiple developers to work on it. we do take regular backups of the file, but proper versioning is not possible. we never know who did the breaking change. the worse thing is we dont know if there is any change at all. diff'ing databases is tedious if not impossible. the tables are expected to grow quite large in years to come and we would need developers to work in parallel on it. the data is business critical. we need to be able to audit changes made to it. ## Question What would be a solution for the problems outlines above? one idea was to transform the whole thing to XML and treat it like just another source file. that way SVN can do the versioning and we can work in parallel. but the data shows relational behavior. with XML we loose the unique and foreign-key constraints. also we cant query it with sql like ease. any help here will be appreciated.


title: What should I know moving from a startup to a corporate role?

text: I recently took a position with a fairly large company. So far, I've worked with small companies (just a few employees) and startups so I've gotten used to a certain style of working. I'm a bit nervous about what to expect and what to prepare for: what should I keep in mind as I transition into a larger corporate workplace?


title: Shared source file between two parts of project

text: I have the following sort of directory structure:               part1         build         src     part2         build         src      Now I have a header file that I would like to include in both parts of these projects, it will contain constants and some macro definitions as well as some utility functions, and I want these to be synchronized between the two parts. What would be the generally acceptable way to format my directory structure? Something like so?               part1         build         src     part2         build         src     share         src      and set up my make files in the `build` directories to also look in `../../share/src` Or is there a more "correct" way of doing this?


title: Should one always know what an API is doing just by looking at the code?

text: Recently I have been developing my own API and with that invested interest in API design I have been keenly interested how I can improve my API design. One aspect that has come up a couple times is (not by users of my API but in my observing discussion about the topic): _one should know just by looking at the code calling the API what it is doing_. For example see this discussion on GitHub for the discourse repo, it goes something like:               foo.update_pinned(true, true);      Just by looking at the code (without knowing the parameter names, documentation etc.) one cannot guess what it is going to do - what does the 2nd argument mean? The suggested improvement is to have something like:               foo.pin()     foo.unpin()     foo.pin_globally()      And that clears things up (the 2nd arg was whether to pin foo globally, I am guessing), and I agree in this case the later would certainly be an improvement. However I believe there can be instances where methods to set different but logically related state would be better exposed as one method call rather than separate ones, _even though you would not know what it is doing just by looking at the code_. (So you would have to resort to looking at the parameter names and documentation to find out - which personally I would always do no matter what if I am unfamiliar with an API). For example I expose one method `SetVisibility(bool, string, bool)` on a FalconPeer and I acknowledge just looking at the line:               falconPeer.SetVisibility(true, "aerw3", true);      You would have no idea what it is doing. It is setting 3 different values that control the "visibility" of the `falconPeer` in the logical sense: accept join requests, only with password and reply to discovery requests. _Splitting this out into 3 method calls could lead to a user of the API to set one aspect of "visibility" forgetting to set others that I force them to think about by only exposing the one method to set all aspects of "visibility"_. Furthermore when the user wants to change one aspect they almost always will want to change another aspect and can now do so in one call.


title: Detect a new tweet with any framework or language (desktop or web-based)

text: I hope this doesnt get perceived as ambiguous or too vague, but i'm attempting to make a service that monitors twitter and archives tweets. Apart from PHP cron jobs i cant think of any way to detect if there has been a new tweet posted? I'm not too fussed about what programming language i have to write it in, or what framework i have to work in. Also whether its desktop or web based. What route would everyone go down for this? Thanks


title: Algorithm to update priority ordered list where changing priority of an item is expensive

text: I am working against an API where I can add and update items in a list that is ordered by a priority field I can set (which need not be contiguous but must be a positive integer). Updating a list member is an expensive operation, so I want to minimise the number of updates. What I want is an algorithm that will minimise the number of updates required when the list is reordered. i.e. The worst case scenario for this is to use contiguous priorities starting at 1. e.g.               Priority  | item     ----------------     1           A     2           B     3           C     4           D     5           E      In this case to move item E to the top of the list, every single item would need to have its priority updated. The naive solution I have though of is to implement large numbers for priorities, and put in priorities that are half way through the interval between two items when an item needs to be placed there. e.g.               Priority  | item     ----------------     1000000     A     2000000     B     3000000     C     4000000     D     5000000     E      In this case to move E to the top only one update is required (and I can set its priority to 500000) The issue with this is that it will act like a binary search, and even in the case of using starting numbers of the order of 10^9 it will only take 30 operations until the priorities could become contiguous. Is there a better algorithm than this? Is there an existing one I can use (but have not found via google), or can someone suggest an improvement to this?


title: How to transition from "help vampire" to "developer"?

text: I've been a computer enthusiast my entire life, but didn't first start programming (web development) until I began College. It is now four years later - I am about to graduate, have had a handful of full-time internships and part-time work, all revolving around web dev... But I still find myself more often than not seeking out help, tutorials or stackexchange answers to my questions instead of working out problems entirely on my own. I hear the term "help vampire" -- someone who asks/seeks help with their problems rather than work through issues themselves -- and while that isn't true for me a hundred percent, I find my threshold of getting "frustrated" when trying to accomplish something is quite low and it doesn't take long once I've found a problem to start searching online for a solution, as opposed to work one out myself. I am certainly able to do my work, but I want to know how I can actually learn to THINK and REMEMBER like a developer, as opposed to relying on online answers as a crutch. It's a nasty habit and I really feel like it's limiting my development potential, speed, flexibility and adaptation to new languages/environments. _TL;DR: How did you transition from seeking help (whether in the form of Q &A's, plugins, tutorials, code-inspecting, etc) to developing solutions (answering the Q&A's, writing your own plugins, creating the tutorials, etc)?_


title: What exactly does it mean that storing “large blobs in the database reduces performance”?

text: To someone who knows database internals this may be an easy question, but can someone explain in a clear way why storing large blobs (say 400 MB movies) in the database is supposed to decrease performance and what exactly does that mean? This is a claim often found throughout the internet, but I've never seen it really explained. To be specific, I'm referring to SharePoint/MSSQL performance, i.e. file- upload performance, site browsing, displaying lists, document opening etc. - operations that are said to become slower once a database gets too big. Blob externalization to filesystem (which in SharePoint is called Remote Blob Storage, aka moving files out of the database, leaving only a reference) is supposed to solve this to an extent, but what exactly - at the bottom level - is the difference? It's obvious that backups would take longer with giant files stored in the database ... but what operations exactly are impacted and what's the underlying mechanism of it (i.e. in what way are files stored on filesystem outside of the database accessed or stored differently)? Suppose a simple table containing columns `ID(guid, PK), FileName(string), Data(varbinary(max))` \- would large `Data` column really slow down operations such as displaying a list of files on a website (which I assume internally means running `SELECT FileName FROM table`), or inserting a new row? It's not like the actual binary content columns are indexed. I know there have been some questions like this asked already, but I've not found an adequate explanation.


title: Properly licensing FOSS: text location

text: I have a few FOSS projects that I want to release under the BSD license, since I only wish to maintain the intellectual property of the code, that others will know I've been writing it. I suppose all I need to do is:   1. Have a file called `LICENSE` only in the main folder of the software.   2. Write at the top of each source file the following text: > This software is released under the BSD License.   >  Full text of the license can be found in the file named 'LICENSE' at the > main folder of the software.   >  Copyright (c) 2013, Dor. Am I correct? Is there anything to add/remove/change?   Should I include my full name,   or may I just use the first name and first letter of last name (e.g. `Dor K.`)? The BSD license text that's contained in the file `LICENSE` is:               ------------------------------------------------------------------------     This software is released under the BSD License     ------------------------------------------------------------------------     Copyright (c) 2013, Dor K.     All rights reserved.          Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:           * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.      * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.          THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     ------------------------------------------------------------------------


title: What's the point of Continuous Integration services like Travis CI?

text: As far as I can tell, services like Travis CI and CircleCI take your project and run its test suite whenever you push a new change to your repository. Assuming that it's also possible to either manually or automatically run such test suite locally before you commit or push your change, what's the point in using a service like this?


title: Rest Api Client response handler

text: I have two instances of Laravel: `Rest Server` API and `Rest Client`. Let's say I want to display list of positions on the front page. I'm making request to my Server API from my client controller:               public function add_employee() {         $data['employee_positions'] = Client_API::generic_request('/employees/position_list');         $this->layout->content = View::make('employees.add_employee')->with($data);     }      If my API request returns 400-500 errors, I want my application be redirected to login page. Where should I validate my API responses? I can't do redirects in my Client's `Client_API` wrapper class. So far, the only way I can accomplish it is by validating responses before returning them inside `Client_API` class and in case of `400-500` error - I'm throwing Exception, and then handling my business logic (redirects) inside catching exceptions function. I've been told that Exceptions shouldn't be used as a part of business processes inside my application.


title: Building Websites: Fast Debugging Without a Browser

text: Is there a methodology to debug websites without a browser? Normally I use a web browser to view a results page. The slow debugging process confuses me a little. To correct an error I need to switch to a code window (which takes some time). Then I correct the error and return to a browser window, press F5, and wait for the page to update (which could take 10 secs). It could take only 1 second if the page automatically updates after I correct my code. I'd like a tool where I could see my code and a corresponding result page on one screen. I need a tool that updates an open page upon code changes. I would also like to edit both server and client sides (generally JavaScript), and see my changes as soon as possible, without unnecessary 'user' manipulations. **Update**. I need a tool which controls source files. It must reload a browser when any source file is changed. A good feature can be reloading with cache clear (for example if a changed file has specific extention such as .js, .css).


title: Software Bug Bash Tips

text: I am trying to put together a bug bash at my office and I was what was the best way to conduct it. Ideally, I'm looking for the most effective way to manage testing and provide the staff with incentives to find relevant errors.


title: Should I not show all my skills?

text: I have been programming for a very long time and I have in depth knowledge of several technologies. Recently I applied for a web development job and in my resume I had listed all the skills - HTML, CSS, JavaScript, jQuery, AJAX, PHP, ASP, JSP, C/C++, ARM. Except for C/C++ and ARM I had shown the skill level for all technologies as expert. Many of my friends had applied for the same job and they did not have any web development experience. ALL of them got a call for interview. However I got a rejection saying that we have received applications from very high level candidates and you have not be selected to go to the next level. This has seriously demotivated me. I do not understand why I have been rejected when I had all the required skills and all those who did not have any of the skills have been selected. One reason which I think is that the employer might be thinking that how one person can be an expert in all the technologies. Once in another interview I was told by the HR manager that it is unbelievable that you know ASP, JSP and PHP all in depth as we have different programmers for each of the technology. Such incidents make me very unhappy as in spite of being highly capable of the position I am rejected. Should I not list all my skills in the resume to avoid such situations?


title: What do you look at first: the code or the design?

text: If you've just been introduced to a new project, what's the first thing you look for to get an idea of how it works? Do you look for the design first? If there is a design, what do you look for in it? Class diagrams or deployment diagrams or sequence diagrams or something else? Or do you go straight for the code? If so, how do you understand how the different layers interact?


title: How to tackle a boss/manager who likes to race the coders

text: After a recent restructuring happened in our corporation - I have got a new line manager. He is generally ok and not as sneaky as the previous one. By "sneaky" I don't mean he was an evil manager - I just refer by this term to someone who keeps most of the information to himself and doesn't share with other team members in order to be the only "go-to person" - you get the idea. But nonetheless I had managed to maintain quite a good relationship with my previous manager - and I had been quite productive. My new boss is more open, which is a good thing, but I really hate one his quality - he likes to race the coders - by giving the same task to a different developer in order to fix the issue ASAP. As you may have already understood the information does NOT flow freely in an environment like ours. So the person who my manager was talking to 10 minutes ago might be starting work on the same issue I am working on now. It happened a few times, and every time I overheard that there might be someone working on the same issue - I did go and ask my manager - who owns the issue - but he usually was very evasive in his answers. So my question is - how to stop my manager from doing it? In our small team of half a dozen developers I am the most senior one and I am usually spared from the racing but when it hits me it really gets to my nerves. And one more thing: I am not implying that my manager is a bad/evil boss, neither I believe in that the world is or should be fair, I just want to find a way to make him stop racing me. One thing at a time.


title: What are the advantages of version control systems that version each file separately?

text: Over the past few years I have worked with several different version control systems. For me, one of the fundamental differences between them has been whether they version files individually (each file has its own separate version numbering and history) or the repository as a whole (a "commit" or version represents a snapshot of the whole repository). Some "per-file" version control systems:   * CVS   * ClearCase   * Visual SourceSafe Some "whole-repository" version control systems:   * SVN   * Git   * Mercurial In my experience, the per-file version control systems have only led to problems, and require much more configuration and maintenance to use correctly (for example, "config specs" in ClearCase). I've had many instances of a co- worker changing an unrelated file and breaking what would ideally be an isolated line of development. What are the **advantages** of these per-file version control systems? What problems do "whole-repository" version control systems have that per-file version control systems do not?


title: IOS Variable vs Property

text: Just started diving into Objective-C and IOS development and was wondering when and the correct location I should be declaring variables/properties. The main piece of code i need explaining is below: Why and when should i be declaring variables inside the interface statement and why do they have the same variable with _ and then the same one as a property. And then in the implementation they do @synthesize tableView = _tableView (I understand what synthesize does) Thanks :-)               @interface ViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>      {         UITableView *_tableView;         UIActivityIndicatorView *_activityIndicatorView;         NSArray *_movies;     }          @property (nonatomic, retain) UITableView *tableView;     @property (nonatomic, retain) UIActivityIndicatorView *activityIndicatorView;     @property (nonatomic, retain) NSArray *movies;


title: How to decide which classes are necessary for the system

text: I know design principles and design patterns in theory. But it's embarrassing to realize that it's not clear when applying it in practice. For example, let's think about simple tic tac toe console game. How would you decide what class is for certain responsibility and how do you determine that responsibility/class is necessary for the system even before applying design patterns or principles? I understand it should be based on requirements and domain knowledge, but there are lots ways to satisfy the requirements. If I take agile (TDD) approach, there are still many ways to achieve the key requirement by making it testable. I wish there are many materials (books or web sites) on this but most of them are on theory but rarely on practices. I would appreciate if anybody can refer to such materials with which I can practice the class designs.


title: I don't program in my spare time. Does that make me a bad developer?

text: A lot of blogs and advice on the web seem to suggest that in order to become a great developer, doing just your day job is not enough. For example, you should contribute to open source projects in your spare time, write smartphone apps, etc. In fact a lot of this advice seems to suggest that if you don't love programming enough to do it all day long then you're probably in the wrong career. That doesn't ring true with me. I enjoy my work, but when I come home from the office I'm not in the mood to jump straight back onto the computer and start coding away until bedtime. I only have a certain number of hours free time each day, and I'd rather spend them on other hobbies, seeing friends or going outside than in front of the computer. I do get a kick out of programming, and do hack around outside of work occasionally. I'm committed to my personal development and spend time reading tech blogs and books as a way to keep learning and becoming better. But that doesn't extend so far as to my wanting to use all my spare time for coding. Does this mean I'm not a 'true' software developer at heart? Is it possible to become a good software developer without doing extra outside your job? I'd be very interested to hear what you think. _Update: thanks everyone for your comments & answers. A lot of good thoughts and advice!_


title: How should I deal with nested compositions?

text: I came across the following question on a website for interviews: > Here are 3 products: table, chair and bench. Product can be of material: > wood, metal, and plastic. Design class structures for this. My first thought was to have an abstract class Product with a protected Material class member as shown below. My actual question is after the code block below               #include <stdio.h>     #include <string>     using namespace std;          class Type {         public:         // Commented out virtual below. Was a typo !         /*virtual*/void SetType(string s) {             m_typeName = s;              }         virtual void PrintType() {              printf("Type = %s\n",m_typeName.c_str());          }         virtual ~Type()=0;         Type& operator=(const Type& rhs) {             if ( &rhs != this ) {                 m_typeName = rhs.m_typeName;             }             return *this;         }         private:         string m_typeName;     };     Type::~Type() {}          class Wood: public Type {     };          class Plastic: public Type {     };          class Product {         public:         Product():m_type(NULL) {         }         virtual void SetType(Type* t){             m_type = t;         }         virtual void PrintInfo() {             printf("I am %s product\n",m_productName.c_str());             m_type->PrintType();         }         virtual ~Product()=0;         protected:         string m_productName;         Type* m_type;     };     Product::~Product() {}          class Table: public Product {         public:         Table() {              m_productName = "table";         }     };          class Chair: public Product {         public:         Chair() {              m_productName = "chair";         }     };          int main()     {         Plastic *p = new Plastic();         p->SetType("plastic");              Table *t = new Table();         t->SetType(p);              t->PrintInfo();              delete t;         delete p;              return 0;     }      However, I have a feeling it could be designed better. In general, if your compositions (Product in the example) contain compositions (Material in the example), what is a good design pattern?


title: Are two database trips reasonable for a login system?

text: I am designing a login system for a project, and have an issue about it requiring two trips to the database when a user logs in.   1. User types in username and password   2. Database is polled and password hash is retrieved for comparative purposes (first trip)   3. Code tests hash against entered password (and salt), and if verified, resets the session ID   4. New session ID and username are sent back to the database to write a row to the login table, and generate a login ID for that session. EDIT: I am using a random salt. Does this design make sense? Am I missing something? Is my concern about two trips unfounded? Comments and suggestions are welcome.


title: Who was your mentor? Where can I find mine?

text: In many of articles I've read, finding a mentor is often suggested. One to who would guide, teach and more. (I wouldn't know the details, I don't have one, yet.) So, who was your mentor, if any? I have only had indirect mentors: professor at university, manager at work whom I've watched and learnt from the most. And otherwise, Twitter has been a great place to follow the professionals and discover more about the technologies that interest me. But I still wonder how I could find one because I can sense that I might be lacking in my experience. Ideas?


title: What the correct algorithm to invert italics in a mixed text?

text:
The question motivations was depicted in the section below. There are many ways to make text italic, so, perhaps, there are more than one good " ** _swap italics algorithm_**". The problem reveals some aditional dificulties in a XHTML code, and using the `<i>` tag, that **must to be balanced**. Example:
Several more Homo sapiens fossils were discovered.

Several more Homo sapiens fossils were discovered.
      So, looks like this,   1. _Several more_ Homo sapiens _fossils were discovered_.   2. Several more _Homo sapiens_ fossils were discovered. * * * # Algoritms introduction and discussion For " **layout solution** ", the simplest algorithm is checking the `font- style` CSS-property of all text blocks, and invert them with jQuery:               $('#myFragment *').each(function(){        if ($(this).css('font-style')=='italic')            $(this).css('font-style','normal')         else            $(this).css('font-style','italic')             });       But this algorithm not survive to a little more complex test,
FRAGMENT <big>with italics and </big> withOUT.
      The second simplest algorithm is for a **concrete solution** , and was used in the "Examples" section. Have two steps:   1. enclose the XHTML fragment into italics;   2. invert open/close italic tags (ex. `</i>` to `<i>`). That is, writing with Javascript,               var s = '... a fragment of XHTML content ...';     s = ''+        s.replace(/<(\/?)i>/mg,                function (m,p1){                   return p1? '': '';               }        ) +        '';        But also not survive to the second test, losting balance of tags... The "corrected" algorithm runs (!), but is not portable, neither fast or elegant. It is demonstred here, and at the example section below. # The point! So the question is, **there are a simple, good and generic (usable in any browser and portable to another languages) algorithm?** You know another "swap italics algorithm"? PS: "generic" in the sense that I even translate your algorithm to XSLT. The algorithm **must produce directallybalanced XHTML code** (without a intermediary blackbox like Tidy). * * * ## Motivations I need to port the "swap italics algorithm" to text editors, server parsers, etc. In all cases I can "normalize input" (and output) by standard XHTML and `<i>` tag. I am parsing XHTML text of prose books and scientific articles, exported from different origins and styles... The most texts are exported as "normal text", but a lot of titles (ex. article title, chapter title), and, sometimes, a full chapter or a full text-box (ex. article abstract) are stylized with italics. All these "stylized with italics" must be inverted. Typical cases:   * Transform the original "all chapter italics" into "all chapter normal text": see this case, where in a roughly 300-page book, 8 of the 25 chapters need to be inverted.   * Italicized quotation marks, abstracts, etc. See this example. Need change back to normal, but without lost the emphasis words.   * Writing binomial names of species, in Scientific texts, are usually typeset in italics (or inverted, in a font different from that used for "normal text"). Hundreds of italicized titles (of articles and of article-sections) of XHTML-exported articles must be inverted at my work place. PS: see the example of the beginning of the question ("Several more _Homo sapiens_ ..."). I need also **translate the generic algorithm (of your answer!) to a XSLT library** , where no "tag balancing correction" not exists. ## Examples Implementing in Javascript and PHP a **non-generic** "Swap italics algorithm". A generic one need a general "XML interleaving algorithm"... Here I use browser's (DOM) and Tidy corrections, as an alternative to "interleaving". ### Javascript It runs with complex inputs (!). Illustrating, by an jQuery implementation:                var s = $('#sample1').html(); // get original html text fragment           // INVERSION ALGORITHM: add and remove italics.      s = ""+          s.replace(/<(\/?)i>/mg,                     function (m,p1){                        return p1? '': '';                    }          ) +          "";  // a not-well-formed-XHTML, but it is ok...      $('#inverted').html(s); // ...the DOM do all rigth!      // minor corrections, for clean empties:      s = $('#inverted').html();      s = s.replace(/<([a-z]+)>(\s*)<\/\1>/mg,'$2'); // clean      s = s.replace(/<([a-z]+)>(\s*)<\/\1>/mg,'$2'); // clean remain      $('#inverted').html(s);        // END ALGORITHM           alert(s);      ### PHP, with Tidy The same of Javascript, "translated" to PHP -- the natural translation is using `DOMDocument()` class and `loadHTML`/`saveXML` methodos, but what have the same behaviour than browser's correspondents is the `tidy` class. Shows the same results (!)                $sample1='ORIGINAL <big>with italics and </big> withOUT';      $inverted = '... inverted will be here ...';      echo $sample1;      // Tidy correction      $s = $sample1; // get original html text fragment       // INVERSION ALGORITHM: add and remove italics.       $s = "".           preg_replace_callback('/<(\/?)i>/s', function ($m){            return $m[1]? '': '';}, $s) .           "";  // a not-well-formed-XHTML, but it is ok...       $config = array('show-body-only'=>true,'output-xhtml'=>true);       $tidy = new tidy;       $tidy->parseString($s, $config, 'utf8');       $s = $tidy;  // ... because Tidy corrects!            // minor corrections, for clean empties:       $s = preg_replace('/<([a-z]+)>(\s*)<\/\1>/s', '$2', $s); // clean       $s = preg_replace('/<([a-z]+)>(\s*)<\/\1>/s', '$2', $s); // clean remain       // END ALGORITHM       echo "\n\n$s";


title: Which metric/list should be used to evaluate whole software development team?

text: The title might be seem vague, so let me tell you a little bit history what i am trying to clarify question. I have been hired as a consultant for a corporate's small development division. The company also owns a couple of software development companies. My ex-manager runs a BI team, with reports, analyst and developers. He asked me to evaluate overall design, software development process and code quality. Here what I found:   * Lots of copy/paste code everywhere ( no reuse ).   * Even though they have everything TFS, VS Ultimate etc, they have no build process.   * No Cruise Control.net / Teamcity...   * No unit tests.   * Web Pages with 3700 lines of code, Lots of huge functions ( which can be divided into smaller functions).   * No naming convention both db and c# code   * No 3rd party or open source projects.    * No IoC.   * No Separation Of Concerns.    * No Code Quality Check ( NDepend or FxCope or anything ).   * No Code Review.   * No communication within the team.   * They claim they wrote an application framework ( 6 months, 3 persons), but I would hardly call a framework ( of course no unit test, there are some but all commented out). The framework contains 14 projects, but there are some projects with only one file with twenty lines of code. Honestly, what people are doing fixing bug all the day( which will provide more bugs eventually), they are kind of isolated from community, some team members even don't know github or stack Overflow they probably went there with google but they don't know about it. So here is question, Is This list ok? Or am I being picky? Since I don't have any grudge against them, I just want to be fair, honest and I would like to hear you suggestions, before I would submit this list. And since this list also will be review by software division's manager, I don't want any heart break or something like this. http://www.hanselman.com/altnetgeekcode/ For example I would love to such lists, I can't make references. Here what I think after this question Since sorf of list wanted I will submit it. But I will definetly reference this question and great answers to make my intention clear ( I dont want to be picky a* _*_ *e, I respect what they do, but I believe they can do better) . I will recommend them to take it slowly, use their time wisely, and if they let me I will try to investigate the real problem and try to solve it with them. Not as an enemy or a person who didnt like what they do, as a friend, a person who likes building things.


title: When am I justified in using a License?

text: I recently wrote a little CLI Hangman game in Python; it's not anything huge, but I did write it all myself. I would like to keep the program open and free (GPL ver.3), but it's so small I don't know if I need to/can license it. Is there a certain point where a program becomes "license-able", or can I license any program I write?


title: Is it legal to modify MIT licensed code and sell it?

text: I have a project and I want to use a ready-made script that is licensed under MIT in it. But using this script separately will be redundant. So I've decided to merge my code and the MIT licensed script in the same file. (Let's say I'll modify, improve and/or add new features to it.) I'm planning to sell this work on a market, but is it fair (legally)? NOTE: Meanwhile, I'll put (refer) the MIT licensed script's copyright already in the final file.


title: How to go about designing an intermediate routing filter program to accept input and forward accordingly?

text: My predicament: I designed an app, written in Python, to read my mail and check for messages that contain a certain digital signature. It opens these and looks for keywords. If the message contains these keywords, certain related functions area executed on the computer. It is a way I can control my computer from my cell phone without being there. I am still in the beginning stages and it can only currently remotely open and close applications/processes. The obvious issue is security risks. I hoped to spearhead that by requiring and checking for that digital signature. However, my issue comes when I'd like to make this program usable by multiple users. The idea is that the user will send keywords: username and password, for instance, to log into their personal email account and send messages to it to be parsed. Please ignore the security implications of sending non-encoded passwords through email. (Though if you could help me on that part I'd much appreciate it as well, but currently, that is not the scope of my question.) My issue is designing an intermediary process that will take an email/password to read an email and scan for those keywords. The issue is, that the program has to be accessing an email to read the email for the username/password! I have got myself into a loop and cannot figure out how to have this required intermediary program. I could just create an arbitrary email account and have that check for login-creds, but is there a better way of doing this than that? Also, is there a better way of communicating with a computer remotely than this? Especially if the computer is not a server and is behind a router with only a subnet ip? If I am asking this question in the wrong place, I deeply apologize. Any help would be much appreciated!


title: What Are The Uses of Algebraic Data Types?

text: I'm reading about Algebraic Data Types (thanks to Richard Minerich I found this excellent explanation of the concept). While I think I understand the notion of sum types and product types etc., what I'm not quite understanding is how Algebraic Data Types are useful beyond specifying pattern matching. What other things can one do with ADT's beyond pattern matching? * * * EDIT: I'm not asking what can a developer do with ADT's that can't be done with objects. I'm asking if there are other operations that ADT's allow; for example, can one do additional reasoning about the types involved if ADT's are employed? Do ADT's facilitate some sort of type analysis that wouldn't be possible without them?


title: Visitor Pattern still useful in languages supporting class extensions?

text: Is the visitor pattern useful in languages supporting class extensions? Why bother implementing it, when you have open classes or can subclass. If you want new functionality for a class you could just subclass it, so unless I'm missing something, is it still (very) useful in languages supporting class extensions?


title: Computational intensive application: loading vs. querying database

text: My company has a suite of mature (roots go back 15+ years), computationally intensive applications (simulations) which we use to do consulting work. I work on the simulation/consulting side of the house, not the software development side. I recently learned about a particular feature of the architecture which concerns me: our large (200-500MB, sometimes more) set of input data are first completely loaded into memory from the database. Then, the simulation engine access the input data from memory as it goes. The struck me as "pre-mature optimization" and/or an old-fashioned idea, as I believe there are database servers out there that can be quite fast. The architecture causes another problem, which is our simulation database can only be so big (a little over a GB) before a sim cannot run at all. The chief architect is a scientist, not a software developer, and somewhat hard-headed at that, so I am seeking comments on this question from the community. Is our architecture hurting us? Are there any papers/work/test on the subject-- tradeoffs between database reading as-you-go and a database copy in memory? Any comments or insight would be appreciated. I would like to get schooled up before I take the issue up with my company.


title: In a resume, what all constitutes a Programming Language

text: In your resume, what would you classify as a Programming Language? For instance, under Programming Languages (or a similarly titled section of your resume), do you list C#, Java, C and leave it at that or do you go and add XML (because, well it is eXtensible Markup Language) and XSLT and jQuery and all that too? If you are not going to add jQuery under languages, where exactly would you put it? One resolution to this dilemma would be put in the technologies you have used under the project, but that way, you are forcing the recruiter to go through the projects that you have done rather than giving a highlight of the technologies and languages you are familiar in. What are your thoughts?


title: What are the downsides of leaving automation tags in production code?

text: I've been setting up debug tags for automated testing of a GWT-based web application. This involves turning on custom debug id tags/attributes for elements in the source of the app. It's a non-trivial task, particularly for larger, more complex web applications. Recently there's been some discussion of whether enabling such debug ids is a good idea to do across the board. Currently the debug ids are only turned on in development and testing servers, not in production. There have been points raised that enabling debug ids does cause performance to take a hit, and that debug ids in production may lead to security issues. What are benefits of doing this? Are there any significant risks for turning on debug tags in production code?


title: What's with Delphi's support cycle?

text: ![Delphi support](http://i.stack.imgur.com/OZ3iM.png) This is a chart I whipped together showing the length of _active_ (meaning ongoing bug fixes and service packs) support offered for each version of Delphi. It is based on the published support data obtained from Embarcadero's website. Delphi 2010 and XE are excluded because their active support is still ongoing so they can't really be compared accurately. Ironically, Delphi 7, which was regarded by many to be the most stable until the release of Delphi 2009, had a support cycle three times as long as Delphi 2009. Granted, this chart spans three different companies with three different agendas. My question is why is Delphi 2009's support cycle so short? I understand Embarcadero has a business to run and they don't make money with service packs but really, 12 months? I would expect that of a $10 shareware title with low profit margins not a $900-$3500 world class development tool.


title: Why hasn't C# gained much traction within the opensource community?

text: I'm not expecting C# to be on par with say Java or Python in the open source community, but it still surprises me just how far behind it is. 'Multi language' open source repos like google code or github have barely any C# projects in comparison to the other languages I mentioned. I'd like to see C# and .Net shake off that slight corporate feel and move more into the open source arena but I just can't see that happening. I'd be interested to hear peoples opinion on why this might be?


title: What's Microsoft's strategy on Windows CE development?

text: Lots of specialized mobile devices use Windows CE or Windows Mobile. I'm not talking about smart phones here -- I know that Windows Phone 7 is Microsoft's current technology of choice here. I'm talking about barcode readers, embedded devices, industry PDAs with specialized hardware, etc... the kind of devices (Example 1, Example 2) where Windows Phone Silverlight development is not an option (no P/Invoke to access the hardware, etc.). Since direct Compact Framework support has been dropped in Visual Studio 2010, the only option to develop for these device currently is to use outdated development tools (VS 2008), which already start to cause trouble on modern machines (e.g. there's no supported way to make the Windows Mobile Device Emulator's network stack work on Windows 7). Thus, my question is: What are Microsoft's plans regarding these mobile devices? Will they allow native applications on Windows Phone, such that, for example, barcode reader drivers can be developed that can be accessed in Silverlight applications? Will they re-add "native" Compact Framework support to Visual Studio and just haven't found the time yet? Or will they leave this niche market?


title: Software Developer Interview Question - Fair or Unfair

text: I just phone interviewed with a company for a graduate software developer position and was asked the following questions. I should add that the company concerned are not a database vendor.   1. How does a query optimiser work?   2. If a database was performing badly how would you use the performance logs to find out the problem. I have asked whether they ask such questions of all candidate software developers (graduate or experienced) in a first phone interview. They replied that they like to test their candidates knowledge of database development. I want to write to the company to say that these questions are unreasonable to ask at a software developer interview and to request that my interview be done over. I would like to check the reasonableness of the following assumptions **a)** Those questions cannot be fairly classified as database development questions.   **b)** I think the questions are appropriate for a DBA interview but wholly unreasonable for a software developer interview (experienced or not).   **c)** The first question is only relevant to a database vendor.   **d)** The second question is not fair because software developers typically don't deal with database performance logs as that is the job of the DBA. Perhaps some of you will be kind enough to comment on my assumptions or may have any other suggestions, before I write to the company.


title: Can anyone help solve this complex algorithmic problem?

text: I got this question in an interview and I was not able to solve it.   * You have a circular road, with N number of gas stations.   * You know the amount of gas that each station has.   * You know the amount of gas you need to GO from one station to the next one.   * Your car starts with 0.   * You can only drive clockwise. The question is: Create an algorithm, to know from which gas station you must start driving so that you complete a full circle. As an exercise to me, I would translate the algorithm to C#.


title: How can I take a list of tokens (of variable number) and know what each token means?

text: I have to read a text document with data formatted as follows: (a couple of examples)               07 M W F 1400 1450 C 2004     M W F 0900 1030 EN 2036     06 M T R 1300 1350 EN 1003     17 T R 0900 1015 EN 1052      The problem I'm having is, once splitting up these strings with `.split(" ", -1)`, I get a different number of tokens for many of them, and the position of the difference varies in the first two "sections". The first part of the string is supposed to represent a scheduling code. It's optional, as can be seen by it being missing in the second line. The second area depicts which days of the week this schedule applies to. It could be anywhere from one to five days, but in these examples there are only 2 or 3. Then the rest are pretty much static: Start time, end time, building code and room number. What I need to do is construct multiple objects for this schedule based on this info (one object for each day), and I'm not sure how to proceed. How can I tell, when iterating over the array of tokens, what each token represents? I thought about using a `switch` statement, but that would only work for the days, as there are 5 of them. The following is the code I (tentatively) plan to use for this object.               public class TimeSlot {            private Day day;       private int startTime;    // # of minutes after midnight       private int endTime;       private Room room;       private String slot;            /**        * Default constructor. Create an instance of TimeSlot.        * @param day   day of the week        * @param start start time of lecture represented as minutes after midnight        * @param end   end time of lecture represented as minutes after midnight        * @param room  room the class takes place in        */       public TimeSlot(String slot, Day day, int start, int end, Room room) {         this.slot = slot;         this.day = day;         this.startTime = start;         this.endTime = end;         this.room = room;       }     }          enum Day {       MONDAY,       TUESDAY,       WEDNESDAY,       THURSDAY,       FRIDAY,       SATURDAY,       SUNDAY;     }          public class Room {            private String buildingCode;       private String roomNumber;            public Room(String building, String room) {         this.buildingCode = building;         this.roomNumber = room;       }            public String buildingCode() {         return buildingCode;       }            public String roomNumber() {         return roomNumber;       }          }


title: What are some practical uses of the "new" modifier in C# with respect to hiding?

text: A co-worker and I were looking at the behavior of the `new` keyword in C# as it applies to the concept of hiding. From the documentation: > Use the new modifier to explicitly hide a member inherited from a base > class. To hide an inherited member, declare it in the derived class using > the same name, and modify it with the new modifier. We've read the documentation, and we understand what it basically does and how it does it. What we couldn't really get a handle on is why you would need to do it in the first place. The modifier has been there since 2003, and we've both been working with .Net for longer than that and it's never come up. When would this behavior be necessary in a practical sense (e.g.: as applied to a business case)? Is this a feature that has outlived its usefulness or is what it does simply uncommon enough in what we do (specifically we do web forms and MVC applications and some small factor WinForms and WPF)? In trying this keyword out and playing with it we found some behaviors that it allows that seem a little hazardous if misused. This sounds a little open-ended, but we're looking for a specific use case that can be applied to a business application that finds this particular tool useful.


title: iOS and Server: OAuth strategy

text: I'm trying to working how to handle authentication when I have iOS clients accessing a Node.js server and want to use services such as Google, Facebook etc to provide basic authentication for my application. My current idea of a typical flow is this:   1. User taps a Facebook/Google button which triggers the OAuth(2) dialogs and authenticates the user on the device. At this point the device has the users access token. This token is saved so that the next time the user uses the app it can be retrieved.   2. The access token is transmitted to my Node.js server which stores it, and tags it as un-verified.   3. The server verifies the token by making a call to Facebook/google for the users email address. If this works the token is flagged as verified and the server knows it has a verified user. If Facebook/google fail to authenticate the token, the server tells iOS client to re-authenticate and present a new token.   4. The iOS client can now access api calls on my Node.js server passing the token each time. As long as the token matches the stored and verified token, the server accepts the call. Obviously the tokens have time limits. I suspect it's possible, but highly unlikely that someone could sniff an access token and attempt to use it within it's lifespan, but other than that I'm hoping this is a reasonably secure method for verification of users on iOS clients without having to roll my own security. Any opinions and advice welcome.


title: Project Management Tool for developers and sysadmins: shared or separate?

text: Should a team of system administrators who are on a software development project share a project management tool with the developers or use their own separate one? We use Trac and I see the benefit in sharing since inter-team tasks can be maintained by a single system where there may be cross-over or misfiled bugs (e.g. an apparent bug which turns out to be a server configuration issue or a development cycle which needs a server to be configured before it can start) However sharing could be difficult since many system administration tasks don't coincide with a single development milestone if at all. So should a system administration team use a separate PM Tool or share the same one with the developers? If they should share, then how?


title: Model Design: Which layers should access resources?

text: I am implementing a model design where DB tables are 'resources', and a model can use many 'resources'. When I return a row from a table, it is represented by an 'item'. (This came from a book by Keith Pope, but I've seen it in several other places too). So, my question is, who should be able to access the resources? In particular:   * From time to time I'm tempted to let controllers access the resource directly, rather than through the model, for very simple tasks like finding a record. Is this OK?   * Many of my resources are accessed by more than one model. For example, the 'country' table is accessed by the Organisation Model, and the User model. Presumably this is OK? Any pointers appreciated, as always!


title: Is there a canonical book on ABAP programming?

text: I am an ABAP programmer with a knowledge of basic ABAP programming and concepts necessary for a beginer. I want to have a deeper understandings of the subject including the small tips and tricks which will be helpful in times of need; I want to have a systematic structure of the concepts which I can search and learn easily. Is there a book out there that's the de-facto standard for describing best practices, design methodologies, and other helpful information about ABAP programming? What about that book makes it special?


title: Taking too long to get skills for entry level programmer position

text: **I don't have the skills for an entry level position as a .Net programmer. I am trying to learn what I need but there is too much to learn and too little time. What can I do?** About two months ago, I went to a job interview for an entry level C# .Net programming/consultant position in NYC. When I heard back from them, they told me that the knowledge gap between what I knew and what they needed me to know was too big and I might have been a better fit if I had 6 months of experience. This was the first interview that I went on since graduating college. before the interview, I read a book on visual C#. Turns out it wasn't a very good book and I was missing a lot of key areas of knowledge such as   * ADO.net   * SQL (I had learned some LINQ)   * A little bit about how memory is handled   * Multiple threaded programming, etc. Because the book wasn't very good, the stuff I did know, I didn't know very well. I felt crushed. I've applied for jobs to gain experience but when recruiters hear that I have no experience they lose interest. I figured that I can at least work on my knowledge. Since then, I read "SQL Essentials" to cover the SQL bit and I found a pretty awesome book that is good enough to clear up what's hazy in my mind and covers almost all of the extra topics. The book is "C# 4.0: The Complete Reference" by Herbert Schildt. I'm even learning a lot about the topics I was familiar with. For a month now I've been working my way through this beast of a book. However, gaining the knowledge I need is taking too long. I can't hold off not having a full-time job much longer. I'm not stupid and I'm studying constantly pouring through the book, asking questions on stackoverflow, referencing the C# specification, etc. I have made great progress but there is just too much ground to cover. I'm on chapter 12 which is about a 3rd through the book. To get an idea of what I know vs don't know, the table of contents is on amazon: http://www.amazon.com/C-4-0-The-Complete-Reference/dp/007174116X **How on earth can someone know enough to function as a programmer in the real world?** **Can I try for a job in academia? Will I have time to finish learning the rest of the C# language or am I just un-hireable?**


title: Http handler for classic ASP application for introducing a layer between client and server

text: I've a huge classic ASP application where in thousands of users manage their company/business data. Currently this is not multi-user so that application users can create users and authorize them to access certain areas in the system. I'm thinking of writing a handler which will act as middle man between client and server and go through every request and find out who the user is and whether he is authorized to access the data he is trying to. For the moment ignore about the part how I'm going to check the authorization and all that stuff. Just want to know whether I can implement a ASP.net handler and use it as middle man for the requests coming for a asp website? I just want to read the url and see what is the page user is trying to access and what are the parameters he is passing in the url the posted data. Is this possible? I read that Asp.net handler cannot be used with asp website and I need to use isapi filter or extensions for that and that can be developed only c/c++. Can anybody through some light on this and guide me whether I'm in the right direction or not?


title: Building a table (DataGridView) while keeping decoupled from Model

text: I'll try to keep this simple.   * Small C# app, dialog based, one has a DataGridView.   * I've got an UpdateTable function in the form that accepts a DataSet and passes it to the DataGridView.DataSource.  The DataGridView has columns defined already.   * I've never used DataGridView and whatnot, so I was doing a bit of testing with it by passing it a DataSet I'd constructed myself.  Using this method gives me the correct number of rows, however the entries were all blank.   * When I set the DataGridViewTextBoxColumn.DataPropertyName to the same as the column names in the DataSet, the entries show up.   * If I remove the premade columns from the DataGridView, I get everything in the DataSet, but the columns are (obviously) unformatted in terms of size, and the column names are the names of the columns in the DataSet rather than easier to read / formatted names. What's a good way to handle this in an MVP implementation, where the View doesn't have to know or worry about what columns will be in the DataSet it's being handed, but the column names can still be formatted properly in terms of size and name?  Should perhaps the Presenter pass in a vector of strings of DataPropertyNames, Column Names, and column sizes, so the View isn't cognizant of it?


title: How to convince management that I can lead a team?

text: I am a developer working with small organization from last two years. I have completed some successful projects and organization believe on my technical skill. Now I get nominated for Team leader position, So how can convince them that I can lead a team ?   What skills I have to show besides technical stuff ? Any help will be appreciated.


title: I'm doing 90% maintenance and 10% development, is this normal?

text: I have just recently started my career as a web developer for a medium sized company. As soon as I started I got the task of expanding an existing application (badly coded, developed by multiple programmers over the years, handles the same tasks in different ways, zero structure). So after I had successfully extended this application with the requested functionality, they gave me the task to fully maintain the application. This was of course not a problem, or so I thought. But then I got to hear I wasn't allowed to improve the existing code and to only focus on bug fixes when a bug gets reported. From then on I have had three more projects just like the above, that I now also have to maintain. And I got four projects where I was allowed to create the application from scratch, and I have to maintain those as well. At this moment I'm slightly beginning to get crazy from the daily mails of users (read managers) for each application I have to maintain. They expect me to handle these mails directly while also working on two other new projects (and there are already five more projects lined up after those). The sad thing is I have yet to receive a bug report on anything that I have coded myself. For that I have only received the occasional let's-do-things-180-degrees- different change requests. Anyway, is this normal? In my opinion I'm doing the work equivalent of a whole team of developers. Was I an idiot when I initially expected things to be different? I guess this post has turned into a big rant, but please tell me that this is not the same for every developer. P.S. My salary is almost equal if not lower than that of a cashier at a supermarket.


title: Are branches in unit tests bad practice?

text: Say I want to assert that a certain option menu is displayed in the front-end of a project. The menu is on screen X and I have to first select data in Y to get to X. Now, it doesn't matter at all what data I select in Y, it will always lead to X. But sometimes, depending on the data, I will get a screen Z which I can just skip through. Now obviously, if I write the test in a deterministic manner the test may fail if the data I selected leads to screen Z. The data I'm talking about is test data, set up before every test to the same state. So theoretically, I could just select one data entry that I know will not go to screen Z. But, I could also simply include a check to see if I'm on screen Z after selecting the data and skip Z. Now, even changes to the test data (though rare, it happens) would not break my test. Somehow I don't like this approach but I can't really explain why. Adding a method to check for Z would add a (probably) "useless" method to my test framework. So my question is, are branches to handle conditional behaviour that is not being tested in that specific test okay? Are there any problems with this approach? Is it good to do this?


title: Data duplication vs Encapsulating. Which design to use?

text: The problem that I face is how to combine encapsulating and optimal memory use. I can't show you my code and therefore explain it on extensive (I hope) example. Let's say we need to have a database of mans. We want to know only 2 things about those people:   1. Age of the man (in hours from birth).   2. Name of the town he lives in. The convenient and natural way to manage this data is to create an object, which corresponds to a man and store it in an array:               class OMan1 {       public:         OMan( const int &age, const astring &t ): fAge(age), fTown(t) {}         const int& age() const: { return fAge; }         const astring& Town() const: { return fTown; }         astring FullId() const: { return fTown+fAge; }       private:         int fAge;         astring fTown;     }          OMan mans[N];      Here our OMans are self-containing object and everything fills nice. Except of the fact that we clone names of the towns thousands of times, and waste memory and execution time this way. An improvement we can do is to make an independent array for town names and for each OMan, store only the age, an id of the town and a pointer to towns array:               class OMan2 {       // same functionality as for OMan1         int fAge;         int fTownId;         astring* fTowns;     }      object is still self-contained, `sizeof(int) + sizeof(void*)` is much less then `sizeof(astring)`, we win a lot. But still it is factor of 2-3 more than `sizeof(fAge)` and we repeat `fTowns` billions of times. Memory optimisation is crucial for me, therefore what I do is keeping only `fAge` and `fTownId` and move such functionality as `Town()` and `FullId()` out of the `OMan` class to some class like `OManDataBase`:               class OMan3 {       public:         OMan( const int &age, const int &tid ): fAge(age), fTownId(tid) {}         const int& age() const: { return fAge; }         const int& TownId() const: { return fId; }         // const astring& Town() const: { return fTown; }         // astring FullId() const: { return fTown+fAge; }       private:         int fAge;         int fTownId;     }          class OManDataBase {       // constructor, destructor         const int& age( const int& i) const: { return fMans[i].TownId()]; }         const astring& Town( const int& i) const: { return fTown[fMans[i].TownId()]; }         const astring& FullId( const int& i) const: { return Town(i)+age(i); }       private:         vector<OMan3> fMans;         vector<astring> fTowns;     }      And `OMan3` now is not self contained object. It doesn't know it's fullname, for instance. That means that if I need to do some data processing with one man I have to use whole `OManDataBase` instance:               OBillType47 NewBillType47( const OManDataBase &db, int i ) { ... }      instead of               OBillType47 NewBillType47( const OMan &m ) { ... }      encapsulation has been broken here and the code readability has been clearly decreased. (I put `Type47` to emphasise that I can have a lot of functions, which works with `Oman-S` and can't include all of them into `OManDataBase` class). I wonder **is there any other way(-s) to solve data duplication problem, keeping objects as self-containing as possible**?


title: Why are so many Python files really big (5k+ lines)?

text: Is there any specific reason driving Python files to often be so large? Python files may contain several classes within one file, and some files go up over 10k lines in length. This seems to go against the idea of modularity and encapsulation. Also it doesn't seem "Pythonic" in the first place, considering IMO it can be harder to read and follow.


title: Stick with custom or migrate to CMS?

text: I have a site that has been built from scratch by a few different programmers over time. The first programmer, who built the initial system and database, was not very tech savvy. Other programmers who worked later also did things their own way, taking shortcuts, patching things instead of dealing with root cause issues, as a result I got a website which is buggy and unmaintainable. The site is made for wholesale distributors who come to buy and sell products. They register an account and take advantage of premium features. There is quiet a bit of different things that go on under the hood, for example, to stop fraudsters to continuously registering new accounts, we automatically block their account if any of the previous info they registered with is matched with their new registration info. We also have robot call and verify their phone number. We also developed a system where anyone can send an email to our designated email address, and their email body and subject contents get posted as a buy and sell ad. I want to rebuild the site. I've been thinking that in order to prevent future problems associated with programmers doing things their own way, it is good to migrate the whole site to a CMS such as Drupal or Wordpress and rebuild other features in the form of plugins. That way I suspect, the core, the framework, of the site will remain untouched by programmers, and every time core CMS updates come out, my site remains up-to-date. what do you think? Is this a good idea? Or should I keep the site custom but hire a savvy programmer who could try to fix all the problems, optimize PHP and Database. I also would like to know if migrating my site and database is going to be expensive?


title: Best way to indicate more results available

text: We have a service to return messages. We want to limit the number returned, either allowing the caller to specify the max number to return, or else to use an internal hard limit. We also have thought it would be nice to include in the response whether more messages are available. The "best" way to go about this is not clear. Here are some ideas so far:   1. Only set the "more messages" indicator if the user did not specify a max limit, and the internal max limit was hit.   2. Same as #1 except that "more messages" indicator set regardless of whether the internal hard limit is hit, or the user-specified limit is hit.   3. Same as #1 (or #2) except that we internally read limit + 1 records, but only return limit records, so we know "for sure" there is at least one additional message rather than "maybe" there are additional messages.   4. Do away with the "more messages" flag, as it is confusing and unnecessary. Instead force the user to keep calling the API until it returns no messages.   5. Change "more messages" indicator to something more akin to an EOF indicator, only set when the last message is known to have been retrieved and returned. What do you think is the best solution? (Doesn't have to be one of the above choices.) I searched and couldn't find a similar question already asked. Hopefully this is not "too subjective".


title: How to deal with interactions between many objects

text: I've been working on a game in my spare time. I'm pretty much done defining the primitives and until today everything was pretty well segmented and encapsulated but now it's come time to implement path finding (and other ways for the objects to interact with each other). Here path finding requires at minimum a knowledge of the map, a knowledge of where units are in the map and which types of terrain are passable by the unit whose path is being found. There are three ways I've thought to implement this   * Implement it in some high level class that knows about all of these things already (i.e. a game state object)   * Implement it in some specific method inside one of the "involved" classes (like unit or map) and pass in all relevant state   * Implement it in some function which is completely separate (because no state needs to be retained) and again pass in all of the relevant data I want to get your opinion on which of these makes sense (or if there are others I haven't thought of). I like The first one the most because it only couples the objects at a high level and doesn't require exposing objects to state they don't (otherwise) need to know about. I don't like number 2 because it doesn't do those things and number 3 I'm neutral on at this point; it doesn't seem necessarily better or worse than number 1. If number 2 is in fact the winner I have concerns about how much complexity will be propagated up to this high level game class.


title: Cyclomatic complexity when calling same method multiple times

text: Thanks to a question over at Code Review I got into a little disagreement (which essentially is an opportunity to learn something) about what exactly the Cyclomatic Complexity is for the below code.               public static void main(String[] args) {         try {             thro();             thro();             thro();             thro();             thro();             thro();             thro();         }         catch (NullPointerException e) {         }     }          private static Random random = new Random();          public static void thro() throws NullPointerException {         if (random.nextBoolean())             throw new NullPointerException();         System.out.println("No crash this time");     }      When writing this code in Eclipse and using the Eclipse metrics plugin, it tells me that the McCabe Cyclomatic Complexity for the main method is 2, and for the `thro` method it says 2. However, someone else tells me that the complexity of calling `thro` multiple times is `number of calls * method complexity`, and therefore claims that the complexity of the main method is 7 * 2 = 14. Are we measuring different things? Can both of us be correct? Or what is the actual cyclomatic complexity here?


title: Booking system (Handle working hours, Get available time slots)

text: I'm currently working on a time booking system for a friends hair salon. The plan is to try to keep it as simple as possible. The user view (where the owner see the booked appointments) is more or less complete so now it's time to start working on the view where the customer book their appointments. The thing is, it feels a bit overwhelming and I really don't know where to start. # Problem 1 (work schedule): The system is meant to be used by two persons and their working hours could differ a bit. What would be the best solution to store their work schedule? I did plan to place them in a own table but I couldn't come up with any good table layout. ## Table example:               tbl_workschedule         int_id                       int_dayOfWeek                int_user_id              time_startTime           time_endTime      If I use this kind of layout I could end up with table content like the one below. The feeling I get is that it doesn't look like a good solution?               int_id  int_dayOf Week  int_userID  time_startTime      time_endTime     1       1               1           08:00               17:00     2       2               1           09:00               18:00     3       3               1           08:00               17:00     4       4               1           11:00               19:00     5       5               1           12:00               20:00     6       6               1           08:00               17:00     7       7               1           00:00               00:00     8       6               2           07:00               16:00     9       6               2           12:00               20:00     10      6               2           08:00               17:00     11      6               2           08:00               17:00     12      6               2           12:00               20:00     13      6               2           08:00               17:00     14      6               2           00:00               00:00      # Problem 2 (time booking): ## My basic idea is:   * The customer sign in and choose what kind of service he/she wants. I have a table which contains the different services and how long time each service takes (see db structure in the end of the post).   * The customer choose which hair dresser he/she want.   * The customer choose a date when he/she wants to book an appointment.   * I fetch the working hours for the choosen hair dresser.   * I fetch all booked appointments for the chosen hair dresser that specific date.   * In some way I have to collect all free slots and place them in a array.   * I loop through the free slots array and compare it against the time the specific appointment takes. If I find a free slot that matches I collect it in another array.   * I display the different time proposals to the customer. First of all, is this a good way to handle it? ## My basic idea (more detailed info):   * Fetch the working hours for the specific date and place them in two variables $dayStart, $dayEnd.   * Run a loop that checks the time difference between $dayStart and the start time of the first appointment of the day. If the slot time is more than, let's say the timescale of the service that takes the smallest amount of time I place it in the free slot array. For the next loop sequence I take the end time of the first appointment instead of the $dayStart time and do the same check as described above.   * When the whole day is done I have all free slots in a array like this: array(array(amount of free time, slot start time, slot end time)) E.g: array(array(04:00, 08:00, 12:00))   * Then I, as I wrote above, need to compare the free slot array against the timescale of specific appointment. Here I'm stuck.  * * * Anyone that could guide me in the right direction? Thank you in advance # Database ## Tables: tbl_events               - int_eventID (INT)     - int_serviceID (INT)     - date_eventDueDate (DATETIME)     - date_eventCreationDate (DATETIME)     - int_userID (INT)     - int_customerID (INT)     - int_eventOnlineBooked (INT)      tbl_customers               - int_customerID (INT)     - int_userID (INT)      - str_customerFirstName (VARCHAR)     - str_customerLastName (VARCHAR)     - str_customerEmail (VARCHAR)     - str_customerPassword (VARCHAR)     - str_customerCellPhone (VARCHAR)     - str_customerHomePhone (VARCHAR)     - str_customerAddress (VARCHAR)      tbl_services               int_serviceID (INT)     str_serviceName (VARCHAR)     str_serviceDescription (VARCHAR)     int_servicePrice (INT)     int_serviceTimescale (TIME)      tbl_users               int_userID   (INT)     str_userFirstName (VARCHAR)     str_userLastName (VARCHAR)     str_userEmail (VARCHAR)     str_userPassword (VARCHAR)     str_userCellPhone (VARCHAR)


title: Is it an implementation of a stateful mechanism for Rest API authentication?

text: In many articles about Rest API's best practices, it is recommended to not depend upon sessions on server side since it leads to a stateful mechanism. I currently use Play 2.2 framework, with a mechanism that store the data about logged in user in the Play cache (temporary persistent so). When the user wants to authenticate, it calls a dedicated API that grabs its credentials and if valid, server generates a cookie that will be sent to him. This cookie contains a reference id of the user's data in the Play's cache. Then, each time a user calls an API requiring user authentication, server grabs the user cookie (if any), asks for the cache and checks in there whether user is well already authenticated regarding the validation duration. Here a little sample:               def myApi = userAuthenticatorRequest.securedAction {    //user has to be already logged in         implicit request =>           //do something       }      Should I leave from this solution in order to be compliant with best practices, or should I keep it? Is it really considered as a stateful mechanism? If I understand, this is stateful since a call to a secured API required actually two calls:   * authentication api   * secured api while a stateless would authenticate user directly in the secured api, and thus would be totally independent of any context. Of course, user would have to sent each time its credentials (or API key)


title: Do I deserve a promotion/higher salary?

text: I'm a software developer and have been working at my current employer for almost 2 years. I joined straight out of university, so this is my first real full-time job. I was employed as a junior developer with no real responsibilities. In the last year, I have been given more responsiibility. I am the official contact person at my company for a number of clients. I have represented the company by myself in off-site meetings with clients. My software development role has grown. I now have specialised knowledge in certain tools/products/technologies that no one else here does. My problem is that I am still officially a junior developer, and still earning less than I feel I am worth.   * Am I being taken advantage of?    * How long should I reasonably expect to stay a junior developer before I expect a promotion of some kind?    * What would you do in my situation?


title: Anyone had success with selling source code, at sites like code canyon?

text: Recently I came across two sites that help programmers sell source code - binpress and codecanyon. Anyone have experience/success with sites like these?   Would you use them again? What was good about them? What was bad about them?


title: Use Case level confusion

text: I'm working on the use case model of a web design application something like Dreamwaver, I'm little confusing about to which level should I write the use case model. ex: when the user insert a text should I provide a use cases of:     1. select font     2. select size     3. color     4. Italic     5. bold   ..   ..   ..   or it's enough just providing a use case called "modify text properties"?


title: How can you learn names of methods or classes of a framework or an API?

text: I've been programming C++ for a year now. I've gone through the language features and I've written good programs with it, so I decided to move on to OpenGL. At first it seemed confusing. As I kept going through tutorials it appeared to be easier, but I can't remember the names of classes, methods, arguments, etc. In fact this doesn't just apply for OpenGL; I often get stuck with other frameworks too. I have a program in my head, I know how it would work, but I cannot remember the names of methods or classes to use. My question here is, in a nutshell, what techniques can you use to memorize those names? Does writing it over and over help you grasp it?


title: Achieving multiple tasks within one loop

text: With relation to what's considered good OOP engineering principles, SOLID, DRY, KISS etc I am wondering whether to complete multiple tasks within one loop when easily done. The problem is that this conflicts with some principles (SRP), but could also partially lean in favor of others (DRY, KISS). A simple example would be We have a array of image file paths and we want to complete 4 overall tasks per image               get size of image     resize the image     apply a watermark to the image     apply a border to the image      This could be achieved by using one for each loop on the array, and applying each function one after the other, or we could do this with four separate foreach loops, one for getting the size, one performing a resize and so on for the other tasks. I am trying to adhere to these principles as much as possible to remove any bad habits and improve my coding skills.


title: Is there any copyleft (GPL-like) license with both the Affero and Lesser modifications?

text: Looking for a license that covers public network service, like AGPLv3, but like LGPL isn't infectious. Basically I wrote some useful helper functions I want to allow to be used in any work, including closed-source software, but I want to require improvements to MY CODE to be released back to me and the general public. Can you recommend a suitable license? It should also include some of the other AGPL-permitted restrictions (attribution, indemnity), either in the license text or as permitted variations. EDIT: I should clarify that this software consists only of header files (it is rather template-heavy). So the LGPL obligations of users would be attribution and an offer to provide a copy of the (possibly modified) header file(s) used, per section 3. LGPL section 4 requirements to be enable the user to relink don't appear to apply to header files.


title: What other patterns can I use for this singleton?

text: I have a bit of code which uses a plugin and core model, revolving around four major objects: the `Core`, `Server`, `Logger`, and `Parser`, in slightly particular order. The `Core` acts as the central factory, with a catch: it's bound to a single render context (much of this is graphics related, but the other details are not important). The objects it creates and manages are specific to that core, and multiple cores can be created with different contexts. Cores can never share resources with each other. The `Core` is initialized from a configuration file; more on this later. The `Core` must have, from its creation, a `Server`, `Parser`, and `Logger`. The `Server` handles loading and initializing all the plugins, as well as creating objects from them. It acts as a single, in-process plugin server and object registry, similar in many ways to a STA in-process COM server. As plugins are loaded into the process, not a particular `Core`, I'm fairly sure this is appropriate. The `Server` must have a `Parser` and `Logger`. The `Logger` handles logging messages, particularly errors, to disk. It does very simple pre-formatted file writing, with some basic "log level" filtering. The `Logger` requires a `Parser` for resolving file paths. The `Parser` handles variable replacement, particularly in paths. For example, a plugin may request the file `$(root)/resources/a.txt` and the `Parser` will replace that with the application's root directory; or `$(startup)/a.txt` for the startup directory. Simple stuff. Variables are contained in the `Parser` itself, and many are specific to the thread. However, a few are tied to a single `Core`, and thus enters the... Config file. Each `Core` is initialized from a config file, which contains a multitude of settings: plugins for the `Server`, variables for the `Parser`, and a file for the `Logger`. Each `Core` can use a different config file, and most likely will. In my current model, the `Server`, `Logger`, and `Parser` are singletons. They all must provide a single global instance, accessible from the core and plugins (and each other), potentially before a `Core` has been created. All handle process-level functions, but the `Logger` and `Parser` do handle some `Core`-level functionality. The issue with this is that, in order to make the `Logger` and/or `Parser` `Core`-specific, the `Server` would then need its own instances, which would be potentially lacking important characteristics (like what file to use for the `Logger`). The `Server` also handles work that is _very clearly_ common to the whole process: there's just no way to load a plugin into a single `Core`, that's not how shared libraries work. In a previous version, I had all four of these created when a `Core` was created, and belong to a specific `Core`. This caused some issues and oddities, however: the `Core` loads itself as a "plugin" when it starts up, but the `Server` had the same lifetime as the `Core`, making this seem odd. The `Parser` has a number of variables that belong to the process: the initial directory, root directory, and so on. The `Logger` _must_ precede the `Core` in some way, particularly the plugin-loading stage, so errors can be accurately logged. My questions then are:   * Is this setup too over-engineered? The separation of responsibility between objects seems good, but perhaps too split.   * What design pattern(s), be it singleton or otherwise, is/are appropriate in this case, for these objects?


title: how to break up feature requests into work units

text: Im not a paid developer, I spend two or three hours a day working on a development project as a hobby. As time goes by, I come up with "good-ideas" for the project, that are generally features or bug reports. I would like to manage them using a ticket database. My question is about the "scope" of a ticket. I see from looking at other projects ticketing db that tickets are generally high level features to be implemented, and that these get loosely associated with a feature branch in a VCS. How do you manage the "To do list" associated with a ticket ? Is it better to "re-write" the original ticket into smaller tasks ? How small of a task rates a ticket ?


title: Branching strategy to avoid multiple release branches for different customers

text: I am currently thinking of the following branching strategy   1. Main branch   2. Development branch    3. Feature branch    4. Release branch Basically the whole idea is to have a release branch so that hot fix can be applied quickly for specific release. Here is the issue what if I have an urgent feature that I need to do for a specific customer and I do not want those feature to be applied to other customer using the same release version until it is fully tested. At the same time I do not wish to create multiple release branches for different customers as this will complicate stuff. What is the best way to handle such situation?


title: Using the decorator pattern in a deep class hierarchy

text: How would one use the Decorator design pattern for anything other than trivial toy problems, in a deep class hierarchy? For example, let's say you have the class               class Decorated     : public Foo, Bar, Baz     {     public:       void operation();     };      You would decorate it like this               class Decorator     : public Decorated     {       void operation() { d.operation(); }     private:       Decorated d;     };      The issue I'm having is that Decorated can have many inherited methods (from Foo, Bar and Baz) and the Decorator needs to "redirect" them all to its inner object or the object's state will be split between the decorator and the decorated object. How can one make sure the a Decorator correctly decorates another object and that no methods are called on the decorator instead of the decorated?


title: How do I tell my parents that landing a job is what actually counts?

text: On one side, I just want to get a degree with a 3.0 GPA. On the other side, my parents want more than just a 3. Now here's the thing. I program with a passion. I spend day and night programming. And I ace all my programming courses. However, I do terrible on all my elective courses -- such as writing, history, and all that stuff -- which only leaves me with a 3.1 to 3.2 GPA. And my parents want more. They think that university is like high school, where you need super-stellar grades to get to the next level. But they don't realize that _good enough_ grades will land me a job. And they don't realize that a programmer needs to practice to become good at programming, and that having good skills is what will land a job in a nice software development company. Thankfully, though, they don't threaten to beat me with a baseball bat or anything like that. They just occasionally give me the little "tsk-tsk". But even that little "tsk-tsk" makes me feel guilty for opening up an IDE. And on top of that, I procrastinate because of that feeling of guilt. So now, I want to come clean with them. I want to know what's a good way to do that. **[Edit]** OK, so now, I realized, I should aim for higher grades, as some have suggested below.


title: Is it correct to exclude argument names from function prototypes?

text: I was recently creating a small technical documentation for an application. The document is to be used by newly hired programmers to get acquainted with the application. It is much friendlier than the Javadocs we have, and includes information that usually isn't being documented. When describing a function, I first bring the prototype and than the description, usage, etc. I have to choose to include argument names or omit them in the prototypes. On one hand, argument names are mostly trivial (like `MyClass myClass`), on the other hand they sometimes contain information of the purpose of the argument (which I will indicate when describing the function anyway). I had the same dilemma in C++ when creating a class in two files. Should I include argument names? Does it really work for readability?


title: Specifying Author in Source Code in a Commercial Product

text: Usually there is an `@author` tag in API documentation (JavaDoc, PHPDoc etc). Is it acceptable to use this tag on every function you make in a commercial product?


title: Can there be too much uniformity in coding standards?

text: Is there such a thing as too much uniformity? Where I work we of course have standards including naming conventions, architectures, frameworks to leverage etc. However lately there has been a lot of critiquing of things I would consider more style. For example writing `if` statements in multiple lines vs one line, using the c# `??` null-coalescing operator instead of say `== null`, amounts of spacing for indentations etc. It seems to me this starts getting more into a personal style choice and doesn't need to be uniform across a team or company. What one person thinks reads more clearly another may not. Is there some value to this "extra" uniformity?


title: What does it mean when we say that some function is polynomially bigger/smaller than some other function?

text: I was going over this video lecture on master theorem from Introduction to Algorithm  and while explaining case A of the master theorem professor says that some function `f(n)` is polynomially smaller than some other function at point 53:08 seconds: ![formula](http://i.stack.imgur.com/CxEWP.png) What does it mean for a function to be polynomially smaller than this function? I am confused here as polynomially is not equivalent to poly-logarithmically. Has the professor used the wrong term here ? It is highly unlikely though since he goes on to say the same term a number of times.


title: How to structure a development team

text: I am the manager of a team of 11 software developers who look after my company's web sites / web applications, running up to 4 concurrent projects plus day-to-day support at any time. Within the 11 developers there is a mixture of technical skills, job titles and experience, although the team structure is flat with all 11 developers reporting directly to me. The whole team having a single manager is starting to prove not to scale very well. I am starting to be spread too thinly so want to reduce my number of direct reports. All the ways I can think to do this have significant downsides:   * Have junior developers report to senior ones. This reduces the time spent on development by the best technicians.   * Split the team by software product, e.g. developers 1-6 work on intranet and 7-11 work on external sites, with each section having new team lead (possibly a new job description with more management / mentoring / coaching responsibility than the current senior developers). This adds artificial silos and might make it difficult to get an "intranet developer" to work on an external website if I want them to.   * Keep the structure flat and add managerial support in the shape of Project Managers / Team Administrators just to take the pressure off. This doesn't solve the problem as the team can't go on growing like this forever. Is there a standard way of solving this problem which I am missing? If not, how have others of you solved this problem?