Inspiring a co-worker to adopt better coding practices?

In the Handling my antiquated coworker question, various people discussed strategies for dealing with coworkers who are _unwilling_ to integrate their workflow with the team's. I'd like, if possible, to learn some strategies for "teaching" a coworker who is merely _ignorant_ of modern techniques and tools, and possibly a little apathetic. I've started working with a programmer who until recently has been working in relative isolation, in a different part of the company. He has extensive domain knowledge and most importantly he has demonstrated good _problem- solving skills_ , something which many candidates seem to lack. However, the actual (C#) code I've seen is a throwback to the VB6 days. Procedural structure, Hungarian notation, global variables (abuse of `static`), no interfaces, no tests, non-use of Generics, throwing `System.Exception`... you get the idea. This programmer is a fair bit older than I am and, by first impressions at least, doesn't actively _seek_ positive change. I'm not going to say _resistant_ to change, because **I think that is largely an issue of how the topic gets broached** , and I want to be prepared. Programmers tend to be stubborn people, and going in with guns blazing and instituting rip-it-to-shreds code reviews and strictly-enforced policies is very likely _not_ going to produce the end result that I want. If this were a new hire, a junior programmer, I wouldn't think twice about taking a "mentor" stance, but I'm extremely wary of treating an experienced employee as a clueless newbie (which he's not - he just hasn't kept pace with certain advancements in the field). How might I go about raising this developer's code quality standard the Dale Carnegie way, through gentle persuasion and non-material incentives? What would be the best strategy for effecting subtle, gradual changes, **without creating an adversarial situation?** Have other people - especially lead developers - been in this type of situation before? Which strategies were successful at stimulating interest and creating a positive group dynamic? Which strategies _weren't_ successful and would be better to avoid? * * * ## Clarifications: I really feel that several people are answering based on personal feelings without actually reading all of the details of the question. Please note the following, which should have been implied but I am now making explicit:   * This coworker is only my "senior" by virtue of age. I never said that his title, sphere of influence, or years at the organization exceed mine, and in fact, none of those things are true. He's a LOB programmer who's been absorbed into the main development shop. That's it.   * I am not a new hire, junior programmer, or other naïve idiot with grand plans to transform the company overnight. I am basically in charge of the software process, but as many who've worked as "leads" will know, responsibilities don't always correlate precisely with the org chart.   * I'm **not** asking people how to _get my way, come hell or high water_. I could do that if I wanted to, with the net result being that this person would become resentful and/or quit. Please try to understand that I am looking for a **social** , **cooperative** method of driving change.   * The mention of _"...global variables... no tests... throwing`System.Exception`"_ was intended to demonstrate that _the problems are not just superficial or aesthetic_. Practices that may work for relatively small CRUD apps do not necessarily work for large enterprise apps, and in fact, none of the code so far has actually passed the integration tests. Please, try to take the question at face value, accept that I actually know what I'm talking about, and either **answer the question that I actually asked** or move on. _P.S. My sincerest gratitude to those who -did- offer constructive advice rather than arguing with the premise. I'm going to leave this open for a while longer as I'm hoping to hear more in the way of real-world experiences._


Arguments for storing binary asociations in a single field vs. in a mapping table?

When do you draw the line between relational tables, and fields holding multiple values of a particular type. Let me illustrate in an example below where a PokeMaster can be associated to multiple pokemon of unknown number.               TablePokeMasters         PokeMasterId         PokeMasterName          TablePokeMastersToPokemon <- Side question, what is a good naming convention for a linking table?         PokeMasterId         PokemonId          TablePokemon         LinkId         PokemonId         PokemonName      Vs               Table PokeMasters         PokeMasterId         PokeMasterName         PokeMasterPokemon (ex: Picachu, Charizard, Blastoise) <- parse this in code      Is the second method ever preferred over the first one where there is an unknown number of relationships from one table to another? The only value I can see in the second method is a smaller number of tables, and it is easier to see the relationships right inside of one table, instead of building queries to see the relationships.


Using Bit Torrent for internal release management

We currently abuse our version control system and use it... pretty much as an FTP to store big release binaries (4+ GB). We are seeking to move away from this horrendous practice which has and continues to devolve and take more and more of IT's resources while crippling the integration and release processes. A solution for this would be using P2P file sharing to distribute these release images/binaries, mixing file servers and some key user machines as seeds. So my question comes in two parts:   1. Have any of you resorted to setting up BitTorrent in your intranet to distribute release images/binaries?, if not, what do you think about this idea (which was not actually mine BTW, but I think it is great)   2. Is there open source web-based software for handling publishing of BitTorrent trackers?, so that when there is a new release it can be searchable and display its availability with regards to seeds and leeches? (...you know what I'm referring to) Edit: The intranet is global (e.g. USA, China, Germany, Mexico). Regular FTP could work but it is not as cost-effective.


Ambiguous use of "Controller" in MVC

I have heard two separate uses for the term _controller_ when speaking of the _Model View Controller_ methodology.   1. An intermediary section of code that communicates between the Model and View, tying them together.   2. The module that deals with input, similarly to how the view deals with output. For starters, **which definition is correct?** I have read more that use the first definition than the second, with the second being the first one I learned. In addition, it seems to me that both of those things are useful - indeed, when I've used MVC-like designs, I've used both of those things in some way (even if I only ever called one of them the controller). **Should MVC really be defined in a way that includes both of these things?** That would mean that the architecture contains the model, an input module, an output module, and an intermediate module to connect them all, and that just makes sense to me.


How can you provide a public writeable API and not get spammed?

So say you had a site like StackExchange. Now imagine you created a machine- writeable API capable of posting questions and comments and doing everything your browser can do. Of course, about 5 minutes after launching, you'd have so much spam that you would probably have ran out of room on your database servers and will have been permanently blacklisted from every search engine(except for maybe Ask :) ) So, how can you avoid that spam, while allowing a machine to actually use your API(and/or have automation involved? Is it possible in this day and age? I'd expect there is a human moderator at the end of it, but how do you cut down on the majority of spam to measures capable of being handled by human moderators?


Freelance Web Developer tools

I'm thinking of freelancing and building web sites in my free time. I have experience in C#/ASP.NET, JavaScript/jQuery as well as HTML/CSS and SQL. Thus, I feel like I have sufficient web technologies knowledge to go down this path. What I'm unsure of is if there are any tools which can be used to simplify the life of a freelance web dev. As an example, I once designed an e-commerce website from scratch as a University project, which took around 3 months of hard work to accomplish. The finished product was not even hosted, and I didn't delve into any security aspects. I never even hosted a website or database before! What concerns me is that there are millions of sites out there which can for example be used to create an e-commerce site in minutes. Without having to bother with databases, security and other issues. You don't even need to know how to code in server-side technologies to get these sites up and running. Do professional web developers actually use these tools? If a client had to request an e-commerce site (for example), how would a pro go about developing it? I hear a lot about CMS systems like Joomla and Wordpress, but I think my main problem is that I don't know much about the available tools (other than Visual Studio) and I wouldn't know where to get started. Can anyone guide me in the right direction?


How do you put a price on your source code?

I was asked to sell the source code (along with existing users) of small utility app I created years ago. I've investigated how to put a price on the source code but so far haven't come up with a good solution. I've searched the net, but haven't found anything useful. Then I came across a few others who also sold their source code with users, but their prices seem unrealistically high. For example, one person calculated price per user at about $200. He had 80 users and ended up selling the source with users for $30k. How did he come up with this price? Can I find a good price with this formula: > (number of users x app price) + (app price x num of new users in one year) ? If this is a good formula, how do you price source that doesn't yet have users?


Is what someone publishes on the Internet fair game when considering them for employment as a programmer?

(Originally posted on Stack Overflow but closed there and more relevant for here) So we first interviewed a guy for a technical role and he was pretty good. Before the second interview we googled him and found his MySpace page which could, to put it mildly, be regarded as inappropriate. Just to be clear there was no doubt that it was his page (name, photos, matching biographical information and so on). The content was entirely personal and in no way related to his professional abilities or attitude. Is it fair to consider this when thinking about whether to offer them a job? In most situations my response would be what goes on in someone's private life is their own doing. However for anyone technical who professes (implicitly or explicitly) to understand the Internet and the possibilities it offers, is posting things in a way which can so obviously be discovered a significant error of judgement? EDIT: Clarification - essentially it was a fairly graphic commentary on porn (but of, shall we say, a non-academic nature). I'm actually more interested in the general concept than the specific incident as it's something we're likely to see more in the future as people put more and more of themselves on-line. My concerns are not primarily about him and how he feels about such things (he's white, straight, male and about the last possible victim of discrimination on the planet in that sense), more how it reflects on the company that a very simple search (basically his name) returns these things and that clients may also do it. We work in a relatively conservative industry.


Why the programmer with Ph.D is a bad candidate for the employer?

I have found this comic pic on Steve Hanov's blog: ![enter image description here](http://stevehanov.ca/blog/resume_comic.png) The most of the points are true obviously. What I can't comprehend is, why _having Ph.D is considered as a "bad thing"_? ![enter image description here](http://i.stack.imgur.com/k5jlX.jpg) Any thoughts?


How do you deal with boring repetitive tasks and activities?

When you encounter in your work some boring, repetitive (possibly not- programming) task how do you deal with it? Do you try to automate it immediately? Do you postpone automation till you encounter the task twice? Do you try to delegate it? Do you try to find something interesting in it? What do you do to make the work more joyful? Learn deeper to make it more interesting? Learn deeper immediately or when you need it regularly?


Is Oberon really "a better Pascal"?

Reading Niklaus Wirth, one can notice that despite some popularity of Pascal, he is not glad that Oberon (as a "polished" successor of Pascal and Modula) didn't get much popularity. I never did anything in Oberon, but reading the page Oberon For Pascal Developers I really did not like many of the changes as a Delphi/pascal developer, for example   * forcing the reserved words to be always uppercase   * making the language case-sensitive   * getting rid of enumeration types  What do you think about Oberon, is it really "a better Pascal" from your point of view?


Oracle Java SE Certification

* Which exam(s) should be given for Java certification from Oracle.   * is Oracle 1Z0-851 exam old SCJP ?   * Recommend book which covers Oracle 1Z0-851 exam?


What does value propagation mean?

This may be a stupid question but I am working on an algorithm which calculates intervals for variables in some given constraints. For example there is a function called propagateValues and its description is               `Propagate value ranges for the given constraints`      What exactly is meant by value propagation ? The algorithm I am working is basically trying to simplify sets of constraints by doing a range/interval analysis before querying the solver for a feasible solution (to make solving constraint sets more efficient)


easiest way for push notifications

I wanted to implement real time push notification to one of the apps written in RoR. I don't have any experience with nodejs, nowjs, express or socketio. What would be the easiest way to implement the realtime push notification system?


where is there a good description of the use of the word 'scope' in computer science?

Where is there a good description of the use of the word 'scope' in computer science? In this post of a question about the Java final reserved word one responder implies that scope is textual so each iteration of a `for` loop causes a scope to be resumed as current. Another responder implies scope is time dependent so each iteration is a new scope. In those contexts, it was possible to understand what scope meant even though different people use the word differently but sometimes when I am reading a programming book I am not sure what scope means. What are good qualifiers for the word 'scope'? I suggest 'textual' is one. Can you think of others? Should a qualifier almost always be used or is there a general understanding about contexts that help one perfectly infer the the intended meaning? How is the word 'scope' used when speaking of objects (and object oriented programming) and what qualifiers might be necessary?


Inject specific classes or not

I have a TableSqlBuilder interface which has a method getCreateTableSql. This interface is used in some other class as follows:               function createTable( $tableDefinition ) {         $sql = $this->tableSqlBuilder->getCreateTableSql( $tableDefinition );         $this->db->execute( $sql );     }      The TableSqlBuilder interface has multiple implementations, such as SQLiteTableSqlBuilder and MySQLTableSqlBuilder. SQLiteTableSqlBuilder originally created all SQL itself, and had methods to create SQL for an index or for a field. It turned own that the functionality of these methods was needed on its own at other places, so it has been split off into a SQLiteFieldSqlBuilder and a SQLiteIndexSqlBuilder. These classes are instantiated by SQLiteTableSqlBuilder - they are thus not injected, and SQLiteTableSqlBuilder depends on these concrete classes. I'm unsure if this should be changed to have these field and index sql builders injected. On the one hand this gives more flexibility. It also allows mocking out this behaviour in tests. Then again, the binding and flexibility is currently the same as before the code was split of into new classes. When going with the injection approach, the accepted types could be FieldSqlBuilder and IndexSqlBuilder, both interfaces implemented by the current concrete classes. This however means one can happily end up with a MySqlIndexBuilder in a SQLiteTableBuilder, which is clearly to be avoided. Could also just type hint against the concrete class, pretending it is an interface, which gets rid of the dependency as long as the construction happens outside of the table sql builder. Do you think these collaborators should be injected, or is it a valid exception where it is better to not go all the way?


I Want To Program!

I am highly interested in learning how to program but I am unsure whether I want to lean towards web developing or software programming. Or does computer programming cover both in a nut shell? Where should or how should I start?


URLs with variable query strings and cache

I am developing a media server, the basic functionality is to serve an image, which is done the following way               /media/:id      where :id is the id of the image. You may want to ask for a specific size, with some rules I will provide. Eg:               /media/:id/50x50     /media/:id?witdh=50&height=50      Question: Which option do you think is better? I believe the second one to be more RESTful and beautiful, but we will be using a CDN and varnish for cache, so if we get               /media/:id?width=50&height=50      or               /media/:id?height=50&width=50      we will have 2 hits when we should have 1 Any advice?


As a Europe-based company, is it possible to write a custom iPad application for a customer?

Our customer wants us to write a custom application for him that he can use on a handful of iPads in his company. This application is probably only useful for this one customer (maybe for two or three more in the future, but only after additional customization). I read that if the customer subscribes to Apple's Volume Purchasing Program, we are able to provide him with a custom B2B application. This, however, seems to be restricted to US developers (or customers? or both?). What are the alternatives for Europe-based (or, more generally, non-US) software developers and their local customers?


HTML - Alternative for ID when ID is only unique within a certain scope?

So I feel like this should be a common question but I can't find the answer. Maybe I'm using the wrong terminology. Assumptions:   * IDs are supposed to be unique across the document.   * Class attributes are meant for CSS and should not be used in JS selectors.   * Name attributes are not appropriate ID replacements since they don't work the same on all elements and the html 5 spec changed them (removed from certain elements I think). So given something like: The page has multiple of the same widget. Each widget has a unique ID. I need to be able to reference widget sub-elements like `$("#widgetID relativeID")`. So that relative IDs are unique within widgets but may be duplicated outside this scope. I had been using name for this but it seems this isn't the correct way What is?


Is anyone teaching the application of ethics to programming?

Ethical questions come up more and more in the news, and can be core to a software developers' life. On several occasions this year I was asked for advice that amounts to answering ethical questions, in a computer programming context, and I was surprised to see how much fretting and trouble questions which I consider trivial can lead to. Are there any courses or programs specializing in teaching what is expected of an ethical programmer? Has anyone put together a formal curriculum anywhere?


should Product owner be in product management team

Should the product owner ideally be as part of the product management team? How does one handle the internal stakeholding if the product owner is outside the product management team? We had problems since the product owner was not part of the product management team and there were lot of conflicts.


Does it make sense to generate java classes from class diagram?

As we do design & analysis before development, wouldn't be convenient to be able to generate Java classes from a class diagram?   This would promote more exhaustive design and better codes, right? It's strange that why Google returns tons of tools to generate class diagram from Java classes but not the other way around.


A pattern to "atomically" update a pair of objects

Is there a standard pattern in OOP to kind of "atomically" update a pair of objects, like a pair of bank accounts on a transaction? I would like to have somehow a single public method exposed that does it all at once, but can only come up with ways of doing it by making _two_ calls of public methods to update objects separately. I am currently experimenting with _Racket_ , but i would appreciate examples in any language, or a description of a standard pattern. * * * Here is an example of what i have experimented in _Ruby_ (with which i am more comfortable than with _Racket_ ). I am not concerned with locking here, just with class interface.               class Account       def initialize(total)         @total = total       end            def total         @total       end            def transfer_to(another, sum:)         change_total_by(-sum)         another.change_total_by(sum)       end            protected              def change_total_by(sum)           @total += sum         end          end          a = Account.new(10)     b = Account.new(20)     a.transfer_to(b, sum: 5)     print "New a.total = #{ a.total },\nnew b.total = #{ b.total }"      This works using `protected` instead of `private`.


Drawback of using static method

For methods that **never access instance variable or static variable** and they act just like a function (name-spaced) and they are deterministic base on only the input arguments , I want to ask, are there any consideration if I change all of them to static method? I keep hearing people saying it static method is poor, but I am looking for some real code example on my above case.


Operating systems theory -- using minimum number of semaphores

This situation is prone to deadlock of processes in an operating system and I'd like to solve it with the minimum of semaphores. Basically there are three cooperating processes that all read data from the same input device. Each process, when it gets the input device, must read two consecutive data. I want to use mutual exclusion to do this. Semaphores should be used to synchronize:               P1:                     P2:                     P3:     input(a1,a2)            input (b1,b2)           input(c1,c2)     Y=a1+c1                 W=b2+c2                 Z=a2+b1     Print (X)               X=Z-Y+W      The declaration and initialization that I think would work here are: `semaphore s=1` `sa1 = 0, sa2 = 0, sb1 = 0, sb2 = 0, sc1 = 0, sc2 = 0` I'm sure that any kernel programmers that happen on this can knock this out in a minute or 2. Diagram of cooperating Processes and one input device: ![enter image description here](http://i.stack.imgur.com/zQyu7.png) It seems like `P1` and `P2` would start something like: `wait(s)` `input (a1/b1, a2/b2)` `signal(s)`


Why SQL numeric precision is specified as the number of digits?

I understand that this might be a loaded question. For example, in Sql Server 2008, doing `DECLARE @someNum NUMERIC(10);` means that the range of the variable will be limited by 10 digits. In other languages such as C, Java, etc. the standards for representing whole and fractional numbers are different. The range of the values is being sliced by multiples of bytes, and this is understandable, due to the way hardware works. A language could provide something that most hardware does not yet support, such as a 256-bit integer type, which will work fast on a 64-bit computer, if it is implemented correctly. The numeric types in the databases seem to be not tied to underlying hardware. I understand that the values might need to be null-ablle, which can cost a bit or two, but why such arbitrary precision that does not seem to optimize storage or calculation speed? Perhaps databases do not need to perform numeric computations often. Perhaps digit width of a column is a natural extension of character width. Perhaps SQL was supposed to be a non-programmers language (because it sounds like English :) )? Perhaps history took a weird turn, such as one that allowed the inferior VHS format to prosper. Please help me understand this.


Transaction Design Pattern for MVC and location of responsibility?

I'm designing a pretty standard Spring MVC application, and I'm trying to figure out where the responsibility for transaction management should lie. I've been reading Java Transaction Design Strategies, and the one that I think best suits is the Server Delegate one, where the controller is what manages the transactions, and the services and DAOs are oblivious to the transactions. Somehow, this doesn't feel right. My gut feeling is that the services are the ones that should control the transactions, but I have cases where a controller may call several services to perform an action. How have you handled Transactions in MVC applications before, and where do you consider the best place for handling the transactions is?


uploading MS Access databases to the web

I found an easy system for uploading searchable MS Access databases to the web - it's called Caspio Online (http://www.caspio.com/). However, I would rather not pay a monthly fee just to upload databases to our website. Does anyone know of an open source alternative that will allow me to upload a MS Access 2007 Database to a website, and then build a web form that will search it? The easier the implementation, the better :)


What makes a good interview question for a junior applicant?

We had a debate a few days ago at work about some question we ask during interviews. We are in the on-going process of hiring "junior" C++ developers which is kind-of new to the company (we used to hire only experienced programmers, but those are hard to find in our geographical area). For more experienced applicants, we usually ask C++ questions, some code reading exercises and inheritance, cast, const-correctness, static questions. The goal being to check if the applicant has enough experience with the language (if somebody claims he has 6 years of experience with C++ but can't write a `const` getter, then something is wrong for instance). But for "junior" applicants, those kind of questions don't seem relevant: obviously junior people can't possibly know about all the features of a language, and it is expected of them that they will need some learning time. I thought of asking a question like: "Say you are a given a list of millions of integers. Write some function that computes the average of the numbers." Obviously the main goal of this question isn't to get a perfect solution but to see how the applicant think. First he should ask about the list:   * How are the numbers organized ?   * Are they sorted ?   * Where do the numbers come from ? A file ? Some network socket ?   * Do we know the count of items beforehand ? Then I expect him/her to raise several problems:   * The sum of the integers will likely overflow.   * Do we need an exact average or something close-enough will do ?   * What if the list is empty ?   * ...and so on. Obviously, if the applicant doesn't know what classes, functions to use I tell him/her: he/she could get that information on the Internet in a real situation anyway. Now, some of my coworkers think that is a terrible question because it is vague and open, claiming that "junior" applicants are stressed during interviews and can't think properly, making the test moot. I can see their point, but I still don't agree. So my questions are: is this kind of question acceptable for testing "junior" applicants ? What makes a good "junior" interview question ?


Who first coined the term Higher Order Function and/or First Class Citizen?

I've come to understand that long before Haskell, O'Caml or LISP, higher order functions were an academic research subject and in mathematics, Schönfinkel (in 1967) and Haskell Curry (in 1968) already applied techniques such as currying, but that was before it was available in any programming language. Scheme, according to Wikipedia, was the first language to introduce proper higher-order functions as first-class citizens, but is there anybody we can attribute the original idea to? Maybe Alonzo Church, who invented lambda calculus in the 1930's? More specifically, who coined the following definition, which I saw in various paraphrases around in several books and online resources? > A function is considered to be of higher order when it takes another > function as an argument or when it returns a function. Any function not > taking functions as arguments or as return types is called a first order > function.


Comparison of my own Insertion Sort versus the standard algorithm

I come from a background of making MVC websites and HTML5 applications, and have recently decided to dive into the sort of stuff i wasn't taught at university, namely the things most people would learn on a computer science course. I've been reading a book on algorithms, and the first one it mentions was the Insertion Sort. I didn't really understand it the first time, but I understood the goal, so I had a crack at coming up with my own solution before reading more into the proper solution to see how close I got. I got pretty close, and here is my function in C#:                   int[] SortNumbersTomsVersion(int[] numbersIn)         {             int[] output = new int[numbersIn.Count()];                  for (var i = 0; i < numbersIn.Count(); i++)              {                 int cardsLowerThan = 0;                      for (var n = 0; n < numbersIn.Count(); n++)                  {                     if (numbersIn[n] < numbersIn[i])                      {                         cardsLowerThan++;                     }                 }                 output[cardsLowerThan] = numbersIn[i];             }             return output;         }      The concept of it is that, i start off with a group of numbers. Then, for each number, I compare it to all of the other numbers in the array, to see how many others are lower in value. It then takes the resulting count, and places the current number into an output array at that index. The algorithm goes through all the numbers until they are all at the same location. My question is, _what makes the original better than my solution_? for reference, here is the accepted algorithm outside of a function:                   int temp, k;         for (int i = 1; i < array_size; i++)          {             temp = array[i];             k = i - 1;             while (k >= 0 && array[k] > temp)              {                 array[k + 1] = array[k];                 k--;             }             array[k + 1] = temp;         }


Fighting technical debt as the "lowest developer"?

Let's say you work for a company and what you do is develop software for them. You have no idea of the big picture or maybe slight. What you do have are tasks assigned to you via issue tracking system. You're given tasks, you make them work the way the task describes them, you send them back. Like adding 2 integers:               function add(a,b){return a + b;}      But later, as the project goes forward, you notice that as `add` becomes more complex, you realize that it should have needed some form of architecture, more than just a function that adds parameters and returns a value. However, you didn't know that. In the first place, all they needed was that simple `add`. You didn't expect add to become so complex. The project progresses with more features, which you didn't expect to have in the first place. And in the end, you keep piling up hacks and layer upon layer of functions to avoid breaking/rewriting the existing code. How do you deal with these situations? How do you fight technical debt as "the lowest developer"? **Clarification:**   * You're the "implementer", the lowest in the hierarchy.    * You see the problem, but have no say with the matter.   * I'm not quantifying technical debt or looking for tools.   * Regarding the third "duplicate"     * Refactoring & Rewrite - You are locked to your tasks. You are not paid to do extra.     * Architecture Overview - You know the overall system, but no idea of the architecture.     * Code Freeze - Not your call. You're not management.     * Modularization - No idea of architecture. Modules change as requirements change.     * Automated Tests - None exists.


How to deal with management staff (company owner) that downplays the impact of specs changes?

I work in a small web development company (3 programmers) for a while. During the last year the company had hard times (less projects) and a few co-workers were fired, including our Production Manager. Having this person out of our team mean to us that we have to deal more and more with the company bosses (owners). It's them who meet the clients and discuss about upcoming projects (custom web app for example) We had a meeting with the boss this week about a particular project for which he wants the specs to change (add a few features). I understand that in the real world specs **always** change during a project (I'm in this business for almost 10 years, I already figured that). What I am having hard time with is when the boss keeps trying to **minimize the complexity, the impacts of the new specs** because in his mind those changes are not that hard and should not take a lot more time (especially because he already signed a contract with our client for a fixed amount of money). With one programmer co-worker we joked about that, saying that it's not by adding two wings on a car that you will make plane, it has major impact on the whole design of the vehicle, time required is not the same, so is the same with software. Any idea how we should handle that kind of attitude from a boss? Is it possible to make him change his minding in that kind of situation ?


How do I constructively and professionally deal with anger when I'm on the job?

What do you do when something makes you angry while programming? I usually Slap the mouse Hard on my desk and go get a coffee or anything, just to calm down


How can I estimate the entropy of a password?

Having read various resources about password strength I'm trying to create an algorithm that will provide a rough estimation of how much entropy a password has. I'm trying to create an algorithm that's as comprehensive as possible. At this point I only have pseudocode, but the algorithm covers the following:   * password length   * repeated characters   * patterns (logical)   * different character spaces (LC, UC, Numeric, Special, Extended)   * dictionary attacks It does NOT cover the following, and SHOULD cover it WELL (though not perfectly):   * ordering (passwords can be strictly ordered by output of this algorithm)   * patterns (spatial) Can anyone provide some insight on what this algorithm might be weak to? Specifically, can anyone think of situations where feeding a password to the algorithm would **OVERESTIMATE** its strength? Underestimations are less of an issue. # The algorithm:               // the password to test     password = ?     length = length(password)          // unique character counts from password (duplicates discarded)     uqlca = number of unique lowercase alphabetic characters in password     uquca = number of uppercase alphabetic characters     uqd   = number of unique digits     uqsp  = number of unique special characters (anything with a key on the keyboard)     uqxc  = number of unique special special characters (alt codes, extended-ascii stuff)          // algorithm parameters, total sizes of alphabet spaces     Nlca = total possible number of lowercase letters (26)     Nuca = total uppercase letters (26)     Nd   = total digits (10)     Nsp  = total special characters (32 or something)     Nxc  = total extended ascii characters that dont fit into other categorys (idk, 50?)          // algorithm parameters, pw strength growth rates as percentages (per character)     flca = entropy growth factor for lowercase letters (.25 is probably a good value)     fuca = EGF for uppercase letters (.4 is probably good)     fd   = EGF for digits (.4 is probably good)     fsp  = EGF for special chars (.5 is probably good)     fxc  = EGF for extended ascii chars (.75 is probably good)          // repetition factors.  few unique letters == low factor, many unique == high     rflca = (1 - (1 - flca) ^ uqlca)     rfuca = (1 - (1 - fuca) ^ uquca)     rfd   = (1 - (1 - fd  ) ^ uqd  )     rfsp  = (1 - (1 - fsp ) ^ uqsp )     rfxc  = (1 - (1 - fxc ) ^ uqxc )          // digit strengths     strength =     ( rflca * Nlca +        rfuca * Nuca +       rfd   * Nd   +       rfsp  * Nsp  +       rfxc  * Nxc    ) ^ length          entropybits = log_base_2(strength)      A few inputs and their desired and actual entropy_bits outputs:               INPUT           DESIRED        ACTUAL     aaa             very pathetic  8.1     aaaaaaaaa       pathetic       24.7     abcdefghi       weak           31.2     H0ley$Mol3y_    strong         72.2     s^fU¬5ü;y34G<   wtf            88.9     [a^36]*         pathetic       97.2     [a^20]A[a^15]*  strong         146.8     xkcd1**         medium         79.3     xkcd2**         wtf            160.5          * these 2 passwords use shortened notation, where [a^N] expands to N a's.     ** xkcd1 = "Tr0ub4dor&3", xkcd2 = "correct horse battery staple"      The algorithm does realize (correctly) that increasing the alphabet size (even by one digit) vastly strengthens long passwords, as shown by the difference in entropy_bits for the 6th and 7th passwords, which both consist of 36 a's, but the second's 21st a is capitalized. However, they do not account for the fact that having a password of 36 a's is not a good idea, it's easily broken with a weak password cracker (and anyone who watches you type it will see it) and the algorithm doesn't reflect that. It does, however, reflect the fact that xkcd1 is a weak password compared to xkcd2, despite having greater complexity density (is this even a thing?). How can I improve this algorithm? # Addendum 1 Dictionary attacks and pattern based attacks seem to be the big thing, so I'll take a stab at addressing those. I could perform a comprehensive search through the password for words from a word list and replace words with tokens unique to the words they represent. Word-tokens would then be treated as characters and have their own weight system, and would add their own weights to the password. I'd need a few new algorithm parameters (I'll call them lw, Nw ~= 2^11, fw ~= .5, and rfw) and I'd factor the weight into the password as I would any of the other weights. This word search could be specially modified to match both lowercase and uppercase letters as well as common character substitutions, like that of E with 3. If I didn't add extra weight to such matched words, the algorithm would underestimate their strength by a bit or two per word, which is OK. Otherwise, a general rule would be, for each non-perfect character match, give the word a bonus bit. I could then perform simple pattern checks, such as searches for runs of repeated characters and derivative tests (take the difference between each character), which would identify patterns such as 'aaaaa' and '12345', and replace each detected pattern with a pattern token, unique to the pattern and length. The algorithmic parameters (specifically, entropy per pattern) could be generated on the fly based on the pattern. At this point, I'd take the length of the password. Each word token and pattern token would count as one character; each token would replace the characters they symbolically represented. I made up some sort of pattern notation, but it includes the pattern length l, the pattern order o, and the base element b. This information could be used to compute some arbitrary weight for each pattern. I'd do something better in actual code. # Modified Example:               Password:          1234kitty$$$$$herpderp     Tokenized:         1 2 3 4 k i t t y $ $ $ $ $ h e r p d e r p     Words Filtered:    1 2 3 4 @W5783 $ $ $ $ $ @W9001 @W9002     Patterns Filtered: @P[l=4,o=1,b='1'] @W5783 @P[l=5,o=0,b='$'] @W9001 @W9002          Breakdown:         3 small, unique words and 2 patterns     Entropy:           about 45 bits, as per modified algorithm          Password:          correcthorsebatterystaple     Tokenized:         c o r r e c t h o r s e b a t t e r y s t a p l e     Words Filtered:    @W6783 @W7923 @W1535 @W2285          Breakdown:         4 small, unique words and no patterns     Entropy:           43 bits, as per modified algorithm      The exact semantics of how entropy is calculated from patterns is up for discussion. I was thinking something like:               entropy(b) * l * (o + 1) // o will be either zero or one      The modified algorithm would find flaws with and reduce the strength of each password in the original table, with the exception of `s^fU¬5ü;y34G<`, which contains no words or patterns.


What php programmer should know?

I've dig the database here and didn't found any answer for my question. What is a standard for a php programmer to know? I mean, literally, what group of language functions, mechanisms, variables should person know to consider oneself a (good) php programmer? (I know 'being good' is beyond language syntax, still I'm considering syntax of plain php only) To give an example what I mean:   * functions to control http sessions, cookies   * functions to control connection with databases   * functions to control file handling   * functions to control xml etc.. I omit phrases like 'security' or 'patterns' or 'framework' intentionally as it applies to every programming language. Hope I made myself clear, any input appreciated :) **EDIT 1:** > **Note:** > > Michael J.V. is right claiming that databases are independent from language, > so to put my question more precisely and emphasise differences: > > Practises or security, are some ideas to implement (there is no 'Pattern' > object with 'Decorator()' method, is there?) while using databases means > knowing a mysqli and a set of its methods. **EDIT 2:** It all came to me after some interview task: > Count seconds, days, months, years elapsed since date input till now. So I had opened the php docs to check date functions. After I had done tasks the interviewer told me he wasn't satisfied with my actions since datetime() is something everyone should know. That's why I'm asking all this. What everybody should know..


New to programming, where do I start?

So ... I'm a sysadmin. There are a number of instances where scripting would come in handy(mostly user management ... creating groups, assigning permissions, deleting expired accounts, etc), and I'd like to make a fullblown program. But I don't even know where to start. **Edit** A lot of comments made sense along the lines of "learn what you want to learn." So ... I need to figure out what I want to learn.   A: Is there no such thing as a "beginner" or "building block" language? It wouldn't be any easier to learn C# and move into C++ than it would to just go straight into C++?   B: How do I choose what to learn? I'd like to write a game for my first real project, if that helps narrow it down. (aside from "Hello world" ;) ) There are so many languages out there I don't know where to begin. I don't even know the real difference between C#/C/C++.   C: Once I _have_ picked a language, what's the best way to start learning it?


Being a good mentor

If you had a student or junior developer who was competent but just had no real world experience how do you think it would be best to mentor them or what information could you give them that would ease their transition from newbieness into leetness?


In TDD, if I write a test case that passes without modifying production code, what does that mean?

These are Robert C. Martin's rules for TDD:   * You are not allowed to write any production code unless it is to make a failing unit test pass.    * You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.    * You are not allowed to write any more production code than is sufficient to pass the one failing unit test. When I write a test that seems worthwhile but passes without changing production code:   1. Does that mean I did something wrong?   2. Should I avoid writing such tests in the future if it can be helped?   3. Should I leave that test there or remove it? * * * **Note:** I was _trying_ to ask this question here: Can I start with a passing unit test? But I wasn't able to articulate the question well enough until now.


The importance of using Configuration Management tools in a Software project for controlling the changes

Can we control the changes on a special artifact while our configuration management tool doesn't work properly? Can we do it ourselves?


How to use MVC in practice

I'm very confused. I can't even begin to understand how MVC would be implemented outside of web development. This might seem like too general a question, but how would one apply MVC. I have the following general questions:   1. Are M, V, and C all meant to be one class each, or many. If many, how would that work.    2. Most classes I've made previously have had their data inside them, not in a separate class. How would this work with MVC? 1) For instance, lets say you have a class where you take care of a virtual dog. I would think that you would make a Dog class with, for example, a "bark" command that would play a sound along with a name variable and a coat_color variable. I know this is very simple, but how would this fit inside MVC? It seems that you would end up with MC and V, where the information (model) AND the controls were in the Dog class, which would maybe access swing, or whatever library, to update the view. 2) Or, what about a program like sims (simplified version) where each person would have their own information... would you put all that info in another class? Sorry if these are all based on giant misconceptions, but I'm pretty confused. Right now I'm using Java, if that matters for MVC...


Moment to release an app to the App Store

Is there a good moment to release an app? Is there a bad moment to release an app? For example, maybe Spring/Summer won't get as many sales as the Fall/ Winter. In the sense that kids getting out of school will be spending less time in front of the screen, more time hanging out outside, etc. Any opinions on the matter?


Big project layout : adding new feature on multiple sub-projects

I want to know how to manage a big project with many components with version control management system. In my current project there are 4 major parts.   1. Web   2. Server   3. Admin console   4. Platform.  The web and server part uses 2 libraries that I wrote. In total there are 5 git repositories and 1 mercurial repository. The project build script is in Platform repository. It automates the whole building process. The problem is when I add a new feature that affects multiple components I have to create branch for each of the affected repo. Implement the feature. Merge it back. My gut feeling is "something is wrong". So should I create a single repo and put all the components there? I think branching will be easier in that case. Or I just do what I am doing right now. In that case how do I solve this problem of creating branch on each repository?


Should I expect recent grads to be familiar with basic programming concepts?

It seems there's a HUGE discrepancy between what I expect someone who's studied programming for a few years at university, and what one actually knows. I don't feel like I'm asking overcomplicated questions in interviews. Some of my usual questions are :   * What's the difference between a reference type and a value type?  If it seems the interviewee doesn't really understand his own answer, or if he doesn't know the terminology I'm using, I get into more details by asking him to explain me what happens when I write int i=0; in a method, what about object o=0, object o = new MyClass(), etc... Basically, I do everything I can to trick the interviewee into telling me about the callstack, the heap etc, and I try to stay into language-agnostics concepts. If the interviewee tells me he did a lot of C, or C++, or c#, I dive deeper into the specific language, and possibly into the implementation details. If needed, I ask the interviewee what a callstack is, or where arguments passed to a function in the imperative language of his choice are stored. most of the interviewees have just no idea about what a callstack is, let alone boxing considerations, etc.   * What's the difference between an abstract class and an interface. In which cases should you use one over the other ?  Usually, I also ask them to imagine a design of a small library with a use case aiming at using some inheritance and some abstract factories Most of the interviewee have just no idea of what inheritance real purpose might be. They usually know some keywords (virtual, override, etc), but don't really know when to use them, let alone explaining what a virtual-table is. Even-though I screen CVs beforehand, even for people with 5 years of experience in real life projects involving complex architectures, I would say less than 25% of all my interviewees can answer those two questions properly. And when I say properly, I don't mean 'in-depth'... just to have an approximate idea of what the concept is. Regarding juniors, I'm fine with hiring someone who doesn't know how to organize his time very well, or someone who's not used to industrial build processes for example, but I have the feeling that if one hasn't heard the word "callstack" after a few years of studying Computer Science, he's either stupid, or unmotivated, or chose his university very unwisely. Do you think I'm too extremist here ? Is it common to learn these basic concepts after you've completed university ? Do you know of people who weren't familiar with these, and became very good software engineers after a few years ? And do you think my company might have an issue in attracting talented people, or do you experience the same kind of issues with in your own hiring process? * * * Edit. regarding the "immediate type" thing, it was just a literal translation from French to English, as we usually do our interviews in French. I've fixed it in my question. But still, I think you all understand perfectly what I meant, which kind of makes my point, doesn't it?


difference between passing a value vs passing a function as a parameter in scala

I often hear that scala has a ability to pass function as a parameter to another function. I would like to know the difference between passing a value as a parameter vs passing function itself as the parameter. How the latter approach brings advantage to the programming. If functions are passed as the parameter how the object references are being created since functions are not tied to any objects.


Aspergers Programmer and Learning Difficulties. Best way to overcome them?

I have Aspergers Syndrome, and a effect of Aspergers for me is that I can find it difficult to understand concepts from reading material unless I have some idea or mental visualization about what it is I'm reading - which is often not possible because most the time we read something because we don't know about it in the first place. But, I have to be able to grasp something visually in my head to understand it. I've been programming for a long time (although I stopped programming for 12 months to being charged with a Computer Hacking offence). I've picked up a lot along the way, but also forgot a lot of concepts I don't use often. When it comes to re-learning the material again I have to start from scratch and face the same learning challenge. I tend to find video training courses are easier for me to grasp. Although a lot of video training courses on programming languages don't go into great detail on certain concepts it makes it easier to understand a concept when I pick up a reference manual or an advanced topic book. One thing I find difficult about learning from articles online, or even from the MSDN reference, is that whilst reading there will be a number of topics in the article that I don't understand so I have to pause reading, go to Google, learn the things I don't understand from the previous article, then go back to the previous article. The thing with this approach though is you tend to get stuck in a sort of dependency hell where you're constantly going to Google and other articles before you start traversing back to the original. I have a nasty problem with pride. It's like everything I learn I want to learn the absolute correct way, and if it's not I don't want to know how to do it at all - again the problem with this is there is no way of knowing if something is correct if you don't know about it in the first place, but it limits me to only learning from credible sources. I fear from learning something the wrong way, or learning bad practices that will get me mocked as a developer. Again this is all part of my Aspergers and not something I can completely control. I will often start a project, and if there is something I need to learn, I will pause it to learn how to do something and come back. The problem is I rarely come back to the project because I'm stuck in a cycle of learning. Again, it's the whole pride thing again. I hate copy and pasting other programmers work without fully understanding what it is their work is doing and if there is any way I can improve on it. Having never worked in the commercial industry I have no idea how it works in the work place. I'm not confident to work in a commercial environment, even though numerous friends who are programmers have said I'm more than capable. Infact, these friends consult me constantly for help on programming topics - yet they work in the commercial environment. But again, I feel this is the Aspergers. I'm trying to find a method of working and learning that boosts productivity and get out of this cycle. Any advice from other programmers or programmers with Aspergers?


Best design to create dynamic set of questions(controls ) in silverlight web application?

I have around 15 templates (this will grow) and each template will have around 10-15 questions. Each question can have answers in different format like text box, list box, dropdown, radio button etc. I need to show one template in a page, at a time based on the input I am getting. What would be the best design approach for this?   1. Put questions data in database and Create dynamic control?    2. Putting in xml and display using xslt?    3. Creating static set of templates? Or any other approach? I don't have too much time to do this. I am going to use Silverlight for this.


Gerrit, git and reviewing whole branch

I'm now learning Gerrit (which is the first code review tool I use). Gerrit requires a reviewed change to consist of a single commit. My feature branch has about 10 commits. The gerrit-prefered way is to squash those 10 commits into a single one. However this way if the commit will be merged into the target branch, the internal history of that feature branch will be lost. For example, I won't be able to use `git-bisect` to bisect into those commits. Am I right? I am a little bit worried about this state of things. What is the rationale for this choice? Is there any way of doing this in Gerrit without losing history?


"Don't cross the streams" Database access objects independant of the Data tier in an N-Tier architecture?

I'm adding functionality to our website which performs long-running processes asynchronously using MSMQ. Doing this ansynch, however means we need to notify users when their requests are completed. Using the command pattern, I created an interface* called INotify and composed that into the message class, so the message processing class can simply call GiveNotice() on the message's INotify object. The first implementation, EmailNotify, was more difficult than expected, as I was surprised to discover MailMessage isn't serializable, but got it going. Now I'm working on a new concrete notifier, DBNotify, which will call a SP of some sort and update a status in the main transactional database. I'm tripped up in that I would like to reuse the DAL architecture we've already created, but INotify is a member of the Model project, which is more fundamental than the DAL. Our hierarchy looks like this: Common > Model > DAL > BAL Here's more detail about our particular n-tiers. Bear in mind, I inherited this, so I'm not looking for suggestions on improving it; I'm wondering how to "break the rules." Common is responsible for all "utility" functions which are used many places in the application, things like accessing configuration settings, parsing strings, non-business related functionality. Model is the repository of business objects, what some folks call data transfer objects, collections of getters and setters. I've added some "smarts" at this layer, but only business rules internal to that object, such as "An item's name must begin with an alphanumeric character." DAL is the data access layer, in theory, all that happens here is model objects are moved into and out of the database. BAL is the Business layer; it encapsulates business rules that govern the interaction of objects (i.e. "A form must have at least two items."). So the INotify interface is defined an abstraction to allow the method of notification to vary independently (i.e. email, TXT, twitter, etc) from the message processing. I have created it at the Model tier, which is independent of the DAL tier, so I can't reuse that code without creating a circular dependency. Has anyone else dealt with a business object whose purpose is to interact with a database, and how do you situate that in your N-tier architecture? Before you tell me to use Linq to Sql, great thanks. This is not a technical question (how do I do this), it's a design question (how should I do this). I think the answer is dependency injection, but I haven't ever used it.


`trigger_error` vs `throw Exception` in the context of PHP's magic methods

I'm having a debate with a colleague over the correct usage (if any) of `trigger_error` in the context of magic methods. Firstly, I think that `trigger_error` should be avoided _except_ for this one case. Say we have a class with one method `foo()`               class A {         public function foo() {             echo 'bar';         }     }      Now say we want to provide the exact same interface but use a magic method to catch all method calls               class B {         public function __call($method, $args) {             switch (strtolower($method)) {             case 'foo':                 echo 'bar';                 break;             }         }     }          $a = new A;     $b = new B;          $a->foo(); //bar     $b->foo(); //bar      Both classes are the same in the way they respond to `foo()` but differ when calling an invalid method.               $a->doesntexist(); //Error     $b->doesntexist(); //Does nothing      My argument is that magic methods should call `trigger_error` when a unknown method is caught               class B {         public function __call($method, $args) {             switch (strtolower($method)) {             case 'foo':                 echo 'bar';                 break;             default:                 $class = get_class($this);                 $trace = debug_backtrace();                 $file = $trace[0]['file'];                 $line = $trace[0]['line'];                 trigger_error("Call to undefined method $class::$method() in $file on line $line", E_USER_ERROR);                 break;             }         }     }      So that both classes behave (almost) identically               $a->badMethod(); //Call to undefined method A::badMethod() in [..] on line 28     $b->badMethod(); //Call to undefined method B::badMethod() in [..] on line 32      My use-case is an ActiveRecord implementation. I use `__call` to catch and handle methods that essentially do the same thing but have modifiers such as `Distinct` or `Ignore`, e.g.               selectDistinct()     selectDistinctColumn($column, ..)     selectAll()     selectOne()     select()      or               insert()     replace()     insertIgnore()     replaceIgnore()      Methods like `where()`, `from()`, `groupBy()`, etc. are hard-coded. My argument is highlighted when you accidentally call `insret()`. If my active record implementation hardcoded all of the methods then it would be an error. As with any good abstraction, the user should be unaware of the implementation details and rely solely on the interface. Why should the implementation that uses magic methods behave any differently? Both should be an error.


What reading is recommended for an experienced Java/SQL Developer moving to Apache/Tomcat, Postgres, Hibernate

I am taking over management and development of a website developed in Java using Hibernate and Postgres, running on Apache/Tomcat. I am an experienced Java developer, and have experience in Ruby on Rails, and am expert in Oracle SQL. What is the best documentation for me to read?


Which job opportunity is better? The one with the most learning potential or the most teaching potential?

I have a little over 10 years of development experience. For the past few years, I've mostly been working solo and although it has its perks, I feel as if it has been limiting my growth. I'm looking to pick up a contract job to get back into a team environment. I've been weighing a couple of opportunities: Company A is using the latest tools (.NET 4, VS 2010, ASP.NET MVC). The interview was fairly technical and I definitely felt rusty and didn't do as well as I had hoped. But I did get the offer. Their development process seems pretty mature. I felt like I could be the "dumbest person in the room" at this job, which I think can be a good thing, from a personal growth standpoint. Company B is a step behind platform wise (VS 2008, .NET 3.5, ASP.NET WebForms). After working with MVC, I find WebForms pretty painful. I also got the sense they have a fair amount of technical debt and they're still working on figuring out a good development process. But at least they're aware of it and working on it. That's an area of interest of mine and I feel like I could come in and provide some good ideas both in terms of development process and paying off technical debt. So these seem like two opposing kinds of jobs: one where I have more of an opportunity to learn technically, and one where I might have a better opportunity to come in and effect change. TL;DR - Which job situation is a better: the one with the biggest opportunity to be a student, or the one with the biggest opportunity to be an agent of change?


Fields vs method arguments

I just started writing some new class and it occurred to me that I was adding a lot of method arguments that are not strictly needed. This is following a habit to avoid having state in classes that is specific to some method call, rather than being general configuration or dependencies of the class. Doing so means that a lot of methods that could have no arguments end up with one, two or three. I'd like to hear your opinions on what you think of this tradeoff, and how you go about deciding which approach to take in what situation? Since code is often easier to understand than English when describing code, I created a little gist that has both variants in it: https://gist.github.com/JeroenDeDauw/6525656


Distributing a proprietary application together with GPL software

First, there are many similar questions here, but I found none with direct answers about this _specific_ scenario. If you find a duplicate, please be kind enough to link to the specific answer(s). Also, to avoid question being too broad, consider this specific scenario only. Assume a proprietary Linux application, which links against LGPL libraries dynamically, and does not link against GPL libraries. It also executes GPL'ed binaries from the file system through standard OS APIs though, to perform some actions. Then assume a customized mainstream Linux distribution, with visible trademarked logos etc removed. Then assume a self-contained product, which includes hardware, let's say Raspberry Pi with a bootable SD card with this customized OS. Then it has the proprietary software, which ultimately needs to start when device is switched on. **How to distribute this combination legally?** More specifically, I see (at least) three separate concerns:   1. _In general, how to distribute just the customized Linux distro legally?_ For example, are there tools, or which distros have tools, to download all used default source packages, ready to be included with distribution or archived locally? I think it's sometimes thought, that if you distribute a derivative of a mainstream Linux distro, you do not need to distribute the sources of default packages yourself, or that you can just point to the distro source repositories if someone asks for them, but I'm not sure if this is legally valid way to fulfill GPL obligations.   2. _How to legally include the proprietary software with the distribution?_ For example, is it ok to have the proprietary software already installed in the above mentioned SD? Is it ok to have it uninstalled on the same media, and prompt user for it's installation on first boot? Is it required to have it on separate media or downloaded from the net, and installed from that? What are the limits of "certainly OK" and "certainly not OK", is there any consensus or even legal precedent?   3. _Is executing GPL programs with hard-coded command strings from a proprietary application OK?_ My understanding is, this is OK and does not create a derived work. But if this is an issue, would working around it be as simple as creating an LGPL-licensed wrapper? Or just having the commands in modifiable configuration file (a good idea anyway, regardless of licensing issues)? **Note** : Except for the techincal aspects of first bullet point, I understand that answers here are not any kind of legal counsel, but answers need to be backed up somehow, this site is not for opinion polls.


How can I get better at knowing how to write code right off the bat?

I have been programming for around 3-4 years now (completed my degree in CS where we were taught the Java programming language). Now my question is: > Do many people find it a difficult task knowing how to write code from off > the bat? What I mean by this is that when I approach a task I would normally look on google to find examples of pre-existing programs to which I would cut and pick sections that would be of use to create my programs rather that think totally logically, knowing what I would need to use from the class libraries to puzzle together to reach my end goal. An example of this is say I was creating an animated GUI. Now for that GUI to work I would usually look at other examples on google and piece together code to reach my desired effect, rather than going to the class libraries and working out exactly what I need to piece together a working program as the libraries can be quite daunting in knowing where to start to find sections that would be useful to you! Just wondering if many others do the same as me or if I'm a minority? Don't know if others find it hard but sometimes I just get confused in knowing what classes I would need or what would be the best way to approach a task.


How is your working time distributed between coding and thinking?

...in percentage. For example 60/40 or 90/10 or 100/0. My hypothesis is that the bigger the proportion of time you spend thinking the smaller your code can be as a result (and the less time will be needed to write it down). Think more, write less, in other words. Do you think it is true? As a side note, I think in typical software companies thinking is not part of the culture anyway: you are usually supposed to be sitting there at your computer _typing_ something. You will almost definitely be noticed by your managers if you wander about with a blank look thinking over your next steps with your code. Too bad.


Starting C++ Programming (for a C# Developer)

I am a C# developer. I am planning to learn C++. (I hope I will be able to leverage the OOP concepts from C#] I have a Windows 7 machine.   1. What are the tools that I need to install for C++ development?   2. Are there any good tutorials for switching over to C++ for a C# developer?


What is more standard shortening for "regular expression", "regex" or "regexp"?

I want to know what is more standard way to call regular expression in short way. I have seen both, regex and regexp. Google says regex has almost 2 as much hits that regexp, but it depends on way I search it (when I add "regular expression" after the word, "regex" becomes "regex regular expression", the result is differend). And on stackexchange there is regex tag. :) What is more proper way to shorten it? Perhaps it does not matter. :) But thanks for answer.


When should use of database be preferred over parsing data from a text file?

I was making a Python program to measure the growth of codereview.SE. My approach was to get the "Site stats" shown on the front page and store them on my hard drive. I plan to do this once every day. So far I have made enough to get the stats and append them to a text file. The python script can be viewed on github. The format I am using is the following               22-08-2013          questions 9073     answers 15326     answered 88     users 26102     visitors/day 7407          22-08-2013          questions 9073     answers 15326     answered 88     users 26102     visitors/day 7407      I just ran the script twice to get the format I would be using in the file. Initially this seemed good to me because I would be storing it myself and the format would be the same so it would be easily parsed but not I am not sure. It seems that using a database should be a better here because that way retrieving data should be easier. Just a note, I have never used any database and have no knowledge of SQL, MySQL or any other variants of RDBMS. So this brings me to the question. When should a database be preferred for storing the data over storing the data in a text file? Are there some pointers that I can look for when making decisions about whether I need a database or simple text files? PS: If better tags can be added please do so. I had some doubts about the tags which could be added.


Folder conventions

is there a resource out there that defines programming folder conventions (e.g. the 'bin' folder)? I googled some but didn't find much. Any relevant discussion on the matter is encouraged. **EDIT** : I'm primarily interested in source management, and I'm not really targeting a specific language (I was hoping to get a reference that might include what's common in the big languages [C, C++, C#, PHP, Python, etc]). Sorry, I didn't mean it to be overly vague.


PBI vs User Story

Recently an item has been added to the Product Backlog by product owner which says "When I go to login page from x page, I see an error. I want that error to be removed". It seems to me that this is not a use case, and shouldn't be a PBI (Product Backlog Item). However, when I discussed it, scrum master told me that user stories are not PBIs and, a PBI could be a bug report, a task, a user story, anything, and literally any item that should be addressed first. I'm not sure about this. Also I can't find a good definition of PBI on the web. So, my question is, what sort of **things** can get into the Product Backlog as items? Does a product backlog item maps to a user story? Are they the same?


Is there a convention for using Yeoman in the context of a larger web framework?

I've found Yeoman extremely useful for building out prototypes locally and static mockups that I can share with a team. However, it seems that including its directory structure within the context of a larger framework like Rails, Django, .NET, would be extremely cumbersome, and I can't picture what an efficient workflow might be. There are scads of tutorials that refer to Yeoman and Front End Workflow, but for collaborative development within a larger team environment there seems to be little out there. How to use Yeoman within a framework that is not simply providing a restful API? How to integrate Yeoman within the workflow of a team?


How to handle duplicate files in version control

Right now we use a very simple system for version control. We have a completely flat master repository for our entire product line. As our codebase grows and we add more products to the product line, this starts to present some serious drawbacks. We'd like to move away from this, especially with out flat style, but there are seemingly fundamental problems with a structured approach, so it'd be great to hear how other people handle these common situations:   1. Your code's got multiple duplicate files in separate locations. For example, you have:              ./somedir/source1.c     ./someotherdir/source1.c      All instances of `source1.c` are the same, so when someone changes `source1.c`, they shouldn't have to make the same change to every `source1.c` in each location where it exists. This is kind of where a flat system works, but it means the structure (with `somedir` and `someotherdir` have to be created to create the correct file structure.   1. On the other hand, if you have something like this:              ./somedir/config     ./someotherdir/config      where both instances of config are unique, and they only share a filename. This presents a big problem in a flat system, you end up doing something like keeping them in a flat repository with unique names, and then renaming them as you recreate the product structure. It seems like this is where a structured file system would make things easier, because there would be no inherent relationship between `./somedir/config` and `./someotherdir/config`. Maybe I am approaching this with a fundamentally bad idea of standard idioms, but as I'm sure you are all aware, when you are making big changes to an existing codebase, it has to be more of a transition than a throw-everything- away-and-start-over situation.


Are there advantages to agile practices other than having a working build between sprints?

I recently became interested in agile practices in software development and I since have seen a lot of articles point out that these practices allow for reduced overall costs. The logic behind that usually goes like this: if your requirements change, you can reflect this change in the next sprint backlog and this will lead to reduced cost, because designing the new feature and implementing it is close together in terms of time, so the cost goes down, according to the famous rule that the later you need to make a change to your requirements the more expensive it will be to satisfy that requirement. But mid to big software projects are complex. A sudden change to requirements does not mean you won't have to touch other parts of your system in order to satisfy that requirement. In a lot of cases the architecture will need to be modified very significantly, which will also mean you'll need to re-implement all the features that relied on the older architecture. So the whole point of reduced costs kinda goes away here. Of course if a new requirement calls for a new independent part of the system, that's not a problem, the old architecture just grows, it doesn't need to be rethought and reimplemented. And the opposite. If you are using waterfall and you suddenly realize that a new requirement has to be introduced, you can go and change your design. If it requires that existing architecture is altered, you redesign it. If it does not really mess with it but just introduces a new part of the system, then you go and do all the work, no problem here. With that said, it seems to me like the only advantage agile development has is working feature complete builds between sprints, and for a lot of people and prjects this is not critical. In addition, agile seems like it results in bad software architecture overall, because features kinda get slapped one onto another, agile teams only care that a feature works, not how it works. This seems like that when systems grow in complexity with time, agile development practices actually increase chaos in the overall product architecture, thus eventually resulting in higher costs, since it will be increasingly more difficult to introduce changes, whereas waterfall allows you to perfect your architecture before you release anything. Can somebody please point me as to where I'm going wrong here, because obviously a lot of people use agile in production environments, so I must be wrong somewhere.


Can GC.SuppressFinalize cause performance problems?

I'm being asked to implement IDisposable on objects that are 100% managed resources, which contain no streams, and no large resources. I understand the importance of properly disposing of large resources and unmanaged resources, but what about the other side of the equation? For an object that doesn't benefit from implementing IDisposable (small fully managed objects), what negative impact can GC.SuppressFinalize have, if any?


What should I do and know before I start writing C?

I have a college degree in CS, and learned about Java and OCaml. Java was used as introduction, and in most CS classed, except the theoretical ones. OCaml was part of learning a different programming paradigm. Since OCaml wasn't a successful entry in my CV, I became a better Java programmer. Also, most jobs are for Java programmers. Later on I learned Golang. I know about the simplifications provided by Java, i.e. garbage collection. I also know, that C doesn't do garbage collection and you have to know when to allocate and when to free the memory. But during my education I was never taught to think in this kind of way. We never learned algorithms in the aspect of memory. I feel like I missed something. So my question is, how deep do I have to dig, before I can start writing passable C code, without having myself put obstacles in my way, because of my own crufty code and deep misunderstanding of relevant issues?


How do people manage to write and maintain extremely complex and hard to read code?

Reading SQLite source code is IMO mission impossible. Yet it is a usable piece of quite complex software (it's a full-blown embedded database after all) that can be downloaded, compiled and used from others code and it is constantly updated. How do people manage to write and maintain such extremely complex and hard to read code?


Handling (many) multiple projects in Git in an enterprise environment

One of the advantages of older version control systems such as CVS and SVN in enterprise development is that anyone can connect to source control and see all the projects that the company has. This can make it easier to get a high level view of what kid of development is happening outside your sprint and also keeps everything in one place and easy to find. However, distributed version control systems (Git, specifically) use the repository as their base unit. They work best with one project (or several closely related projects) per repository. This makes repository management more difficult in most enterprise environments where it is not unusual to have more than 25-50 projects to support. As far as I have been able to determine, you have to keep a list somewhere else of all the repos you have. There is software available, like GitHub, that help, but that still is an extra step beyond a single connection string and listing the contents of the repository. What is the best way to deal with the complexity of multiple repositories?


When working with contractors/interns how protective should one be of your codebase?

We're considering hiring a contractor or intern to work with us on our iOS project but this causes me to get really paranoid that we're giving somebody who doesn't work for the company access to our precious codebase. I mean, I could just give them access to the classes I'd like them to work on but that seems rude and it would make it more difficult for them to develop what we need them to. How paranoid should one be about people running off with their entire application?


Testing a file that relies heavily on a static array

I have a .c file that basically manages its own little database of people. There are add, remove, edit and search functions among some others. It has a static array which it uses to store the data. What is a good way to go about unit testing a file like this? Because the array is static I can't put in my own data. Should I employ some trickery and make a function that passes out a pointer to the array that gets compiled out in the production version? Should I just test the functions as is and make the data they way I want it via a series of adds and removes? What is the best way to test a file like this?


Heavy use of static methods in a Java EE web application?

Generally I am asking if this is a norm. The application architecture includes spring and the zk framework. I personally can't help but think this introduces a number of problems. I mean...this is a lot of non synchronized functionality. On top of that we are using an Apache project that, through my browsing of source, appears to use a singleton which has methods that are not thread safe. Changed in a newer version however we are not free to migrate the library at this time. My real question is, is there a justifiable reason for using a large quantity of static methods in a JavaEE application? I was an ASP.NET dev before this and never encountered this. Instincts dictate this is bad architecture but I am unfamiliar with the stack. There are other warning signs such as a lack of conventional generic convention use. Is this the norm? What is foreign in one platform may not be in another.


How do I store the OAuth v1 consumer key and secret for an open source desktop Twitter client without revealing it to the user?

I want to make a thick-client, desktop, open source twitter client. I happen to be using .NET as my language and Twitterizer as my OAuth/Twitter wrapper, and my app will likely be released as open source. To get an OAuth token, four pieces of information are required:   1. Access Token (twitter user name)   2. Access Secret (twitter password)   3. Consumer Key   4. Consumer Secret The second two pieces of information are not to be shared, like a PGP private key. However, due to the way the OAuth authorization flow is designed, these need to be on the native app. Even if the application was not open source, and the consumer key/secret were encrypted, a reasonably skilled user could gain access to the consumer key/secret pair. So my question is, how do I get around this problem? What is the proper strategy for a desktop Twitter client to protect its consumer key and secret?


What is the difference between implementation and realization in Mythical Man Month?

In Fred Brook's Mythical Man Month chapter 4 (Aristocracy, Democracy, and System Design) page 49, he says: > As Blaauw points out, the total creative effort involves three distinct > phase: architecture, implementation, and realization ... > > implementer has plenty to do ... designing module boundaries, table > structures, pass or phase breakdowns, algorithms, and all kinds of tools > > ...Meanwhile, on the realization level there is much to be done also. > Programming has a technology, too. If the machine is a new one, much work > must be done on subroutine convention, supervisory techniques, searching and > sorting algorithm. What is the difference between implementation and realization? To me, architecture is related more with specification descriptions or diagrams, whereas implementation is programming/coding which looks like the same as realization.


What is "Problem Domain"

I have to document my program for a school project and we have section called "problem domain" but I have no idea what to discuss in this section. So the question is: What should be discussed in the problem domain?


Mapping variable inputs to user interface elements

# Background Developing a system for creating eBooks. The data is highly normalized. The eBook designs are packaged as "themes." The themes can be configured with options for: fonts, colours, some layout, and thematic elements (such as squares for bullet lists could become circles, hexagons, or arrows). The options are tightly coupled to the theme. For example, one theme might only allow the user to select certain fonts, while another theme might not have any thematic elements at all, while all themes might provide options for changing the page number layout, theme colours, and content for the header/footer. Creating eBooks is one example of the general class of problem: > The output depends on configurable options; the available options depend on > a particular constraint set. # Problem When a new constraint set (e.g., eBook theme) is created by a developer, the configurable options must be exposed as user interface elements. The user interface elements could be mapped to the options using a descriptive language, or XML. For example:               <group id=”page-number”>       <group id=”text-attribute”>         <string name=”UserInputPage” default=”# / ##” id=”ui-page” />         <colour name=”UserColourPrimary” id=”ui-colour-primary” />         <select name=”UserSelectBullet” id=”ui-bullet”>           <option id=”ui-select-square” />           <option id=”ui-select-circle” />         </select>         <integer name="UserRandomSeed" min="1" max="50" id="ui-random-seed" />       </group>     </group>     <text language="en">       <!-- Tab name -->       <ref id=”page-number”>Page Number</text>       <!-- Group name -->       <ref id=”text-attribute”>Text Attributes</text>       <!-- Display name for select options -->       <ref id=”ui-select-square”>Square</text>       <ref id=”ui-select-circle”>Circle</text>     </text>      The underlying theme implementation (whether PHP, Lua, Java, or C++) would define, expose, and use variables such as:               UserInputPage     UserColourPrimary     UserSelectBullet      Using XSLT, it would be reasonably trivial to convert the above map into sensible UI widgets that correspond to the variable definition in the XML. By creating this map, developers need not explicitly create the user interface, nor worry about either its layout or menu structure. The developer creates a map of the software's input variables and the computer automatically generates the UI. The UI, in this case will be XHTML, but could be XUL or any other representation. # Comparison Frameworks such as JavaServer Faces are similar to this idea; JSF and ADF issues include:   * Too complex with too much overhead.   * Often tied to specific implementation languages.   * The inputs are bound too closely to their final representation. For example:               <h:inputText value="#{helloBean.name}" ... />     <af:selectOneRadio value="#{bindings.x.hints.inputValue} layout="vertical" />      Vertical "selectOneRadio" radio button inputs should not be hard-coded throughout the application. Instead, the final UI representation should be based on intelligent defaults. In the XML example from the problem section, the UI should generate two radio buttons because there are two inputs in the `select` item. Three items would generate a drop-down. One item would create a checkbox. Similarly, the `<string>` could generate any of:   * input in HTML;   * JTextField in Java; or   * QLineEdit using QT4. Also similarly, the `<integer>` could generate a slider or a simple input field. Validation would be performed elsewhere. With HTML, the final look and feel of the item would be driven by CSS, just as with JSF. # Related Somewhat related:   * Development Approach: User Interface In or Domain Model Out?   * http://en.wikipedia.org/wiki/User_interface_markup_language # Question What approach would you take to create such a variable map definition that can then generate UI code?


Configure Jenkins and Tomcat using Puppet on Vagrant

I'm playing with setting up my first `Spring` \+ `jenkins` \+ `Tomcat` CI dev environment. For now it's just a test/fun phase, but in the near future I'll be starting new project with my coworkers. That's the reason that I want development environment virtualized and exactly te same on every development machine, as well as on production server. I choosen to use `Vagrant` and to try to write `puppet` scripts that not only install everything, but also configure everything so each of us will have the same `jenkins` plugins, same `jenkins` and `tomcat` login and password, and literally after calling `vagrant up` we are ready to work. What I managed to do so far is installation of stuff needed and port forwarding. My `vagrantfile` looks like this (comments stripped):               VAGRANTFILE_API_VERSION = "2"          Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|            config.vm.box = "precise32"       config.vm.box_url = "http://files.vagrantup.com/precise32.box"            config.vm.network :forwarded_port, guest: 80, host: 8090       config.vm.network :forwarded_port, guest: 8080, host: 8091            config.vm.network :private_network, ip: "192.168.33.10"                   config.vm.provision :puppet do |puppet|           puppet.manifests_path = "puppet/"           puppet.manifest_file  = "default.pp"           puppet.options = ['--verbose']         end          end      And this is my `puppet` file:               Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }          class system-update {       exec { 'apt-get update':         command => 'apt-get update',       }            $sysPackages = [ "build-essential" ]       package { $sysPackages:         ensure => "installed",         require => Exec['apt-get update'],       }     }          class tomcat {       package { "tomcat":         ensure  => present,         require => Class["system-update"],       }            service { "tomcat":         ensure  => "running",         require => Package["tomcat"],       }          }          class jenkins {       package { "jenkins":         ensure => present,         require => Class["system-update"],       }            service { "jenkins":         ensure => "running",         require => Package["jenkins"],       }     }          include system-update     include tomcat     include jenkins      Now, when I hit `vagrant provision` and go to `http://localhost:8091/` I can see `jenkins` running, so above script works good. Next step is configurating `jenkins` and `tomcat` by extending above `puppet` scripts. I'm pretty green when it comes to CI. After wandering around web I've found few tutorials about `jenkins` configuration (here's one of them). I really want to move configuration presented in this tutorial to `puppet` file, so when I spread my `vagrantfile` and `puppet` file between my coworkers, I will be sure that everyone has exactly te same setup. Unfortunately I'm also green about using `puppet`, I don't know how to do this. Any help will be apreciated.


Tokenizing Text Held in a Rope Data Structure

I am building a text editor which makes use of a Ragel based tokenizer to support syntax highlighting. I am considering the use of a rope data structure to support efficient modifications and undo/redo operations. Is there a standard approach for tokenizing or searching text contained in this type of data structure? Some characters can cause the tokenizer to consume the rest of the stream.


Static methods on a web context

What happens when concurrent requests call the same static Java method running on an application server? Say that a method run takes 2 seconds and receives 100 calls in a given second. The method itself wouldn't read/write outer state. Could it be better to let it be an instance method instead?


Curating projects of deceased friends

A very good friend of mine, and an avid programmer, recently passed away. He left nearly 40 projects on BitBucket. Most of them are public, but a few of them are marked as private. I've decided to take on curation duties for the projects rather than leave his work to disappear. If you have been in the same situation, what did you do? Did you open-source everything? Continue development? Delete it all? I'm very interested to hear other people's experiences. There are a few reasons why some of the projects are marked as private (private projects on BitBucket are visible only to invited users and the original creator):   * One of them is an iOS web app that was free in the app store. I've had to remove the app from the store as I'm shutting down his web sites as a favour to his widow. However, I've already made the app public under the GPL v3 (he was a big GPL supporter).   * One of them contains proprietary code. It can't be open-sourced.   * Others are very much work-in-progress. I don't know if he intended to make them into hosted, paid services or if he wanted to give the code away under an open-source licence when they were finished. Here's a list of the private projects:   * Some kind of living cell simulator that uses SBML along with Runge-Kutta and Euler algorithms to do... something. There's a fair amount of code here but I don't know what it does or how far along it is. No docs.   * An accountacy application; it seems to have a solid DB design behind it but there's little code on top of that.   * A website whose purpose is to suggest good restaurants. Built on yii. Seems to have a lot of code but I'd need to set up a WAMP stack to see how far along it is.   * A website intended to host memorials to people who suffered from the same problem he was. Built on Joomla. I'm not sure how much of the code is just Joomla and how much is custom; again, I'd need to get Joomla running to find out. I'd just introduced him to Mercurial and BitBucket. All of the private projects are single commits of codebases he wasn't using version control with/was previously using SVN. I don't have the SVN repositories so I can't see the commit logs.


Dealing with inflexible programmers

Sometimes programmers who work on a project for long time get inflexible, and it becomes difficult to reason with them. Even if we do manage to convince them, they can be unlikely to implement our suggestions. For instance, I recently joined a project where the build & release process is too complicated and has unnecessary roadblocks. I suggested that we get rid of some of the development overhead (like filling a few spreadsheets) just by integrating defect management and version control tools (both are IBM-Rational tools so integration can be a very easy one-off effort). Also, if we use tools like Maven & Ant (the project involves Java and some COTS products) build & release can be simplified which should reduce manual errors & intervention. I managed to convince others and I'm ready to put in the effort to develop a proof of concept. But the ‘Senior’ developer is not willing, possibly because the current process makes him more valuable. How do we handle this situation without developing friction in the team?


Windows Physical Direct Memory Mapping

I'm a bit disappointed there is almost no discussion of this no matter where I look so I guess I'll have to ask. I'm writing a cross platform memory bench marking application which requires direct physical address mapping rather than virtual addressing. **EDIT** The solution would look something like the Linux/Unix system calls:               int fd = open("/dev/mem", O_RDONLY);     mmap(NULL, len, PROT_READ, MAP_SHARED, fd, PHYSICAL_ADDRESS_OFFSET);      which will require the kernel to either give you a virtual page mapping to the desired physical address or return that it failed. This does require supervisor privileges but that is ok. I have seen a lot of information about shared memory and memory mapped files but all of these reside on disc and are thus not really useful when I'm trying to make a system dependent read. It is very similar to writing an IO driver although I do no need write permissions to the physical address. This site gives an example of how to do it on a driver level using the Windows Driver Kit: NT Insider: Sharing Memory between drivers and applications This solution would probably require Visual Studio which currently I do not have access to. (I have downloaded the WDK api but it complained about my use of GCC for Windows). I'm traditionally a Linux programmer so I'm hoping there might be something really simple I'm missing. Thanks in advance if you know something I don't!


How did Git and Mercurial develop so similarly at the same time?

Git and Mercurial follow similar models and have similar terminology. Mercurial's initial release was was only 12 days after Git's. How did these two projects, in initial development at the same time, end up so similar? Does anyone know the history?