Changing a variable through a series of statements ... What is this technique called?

I'm looking at a function that that has several statements like this:               n = returnDifferentVersionOf(n);      I.e., the value of _the same_ variable `n` changes progressively several times during the course of a subroutine -- rather than a newly named variable being assigned at each change. What is the generic name of this technique (if there is one)? * * * A more full example might be (in Ruby):               # reuse same var     def cromulentize(str="")        str = "wowza" if str.empty?        str += " adios!"        str = str * 3        str.gsub!('a', 'X')        str = str[0..-3]        str.upcase     end      What is that technique called, as opposed to this one:               # uses diff vars     def cromulentize(str="")        non_empty_str = str.empty? ? "wowza" : str        adios_str = non_empty_str += " adios!"        multiplied_str = adios_str * 3        gsubbed_str = multiplied_str.gsub!('a', 'X')        spliced_str = gsubbed_str[0..-3]        upcased_str = spliced_str.upcase     end      (Note that in Ruby the value of a method's last expression is the return value.)


Do I need to add an index on a table with one row?

I'm creating a parameter table in our database. This table will have 1 row with values that are environment specific (production, development, etc). Is there any reason why I should define an index on this table? **Update**   This table is a parameter table which will be used to drive our job queue system. The table will be defined like this:               QueuePrm       LogLvl    integer       ShowMs    boolean       Restart   boolean      This table will only ever have 1 row. No other table in our system will reference it.


Is it advisable to ask employees to create 'work' GitHub accounts?

I've moved all our company Git repositories to GitHub and now I want to add employees to the projects. Since most employees already have personal GitHub accounts, I'm wondering whether I should ask them to create a _work_ GitHub account. The reason that I'm thinking of doing this is to decrease the chances of unauthorized access to our code base since their personal accounts may be well publicized through their personal activity on the site, increasing chances of targeted attacks. Furthermore, if their personal account is ever compromised it won't mean the whole company code is accessible to the hijacker. Since this will bring the burden of maintaining two accounts for the employees I'm wondering whether it is the correct approach and whether it even makes sense. I would love to hear your opinions on this. **Update** Thanks for all the useful insights. I won't set an answer as accepted because of the subjective nature of the question/answers and since I took the best points from several different answers. I have decided to go forward this way: I will remind employees that work- related GitHub e-mail notifications will have to be sent to their work e-mail accounts for practical reasons. Therefore it would make more sense to create work GitHub accounts. If they are willing to use their personal GitHub accounts and connect it to their work e-mail accounts then that's fine. _In any case_ , employees will have to agree in written form to a number of conditions tied to using GitHub. These are related to account security: choosing a secure password using a secure random password generator that is not used with any other account, not accessing GitHub through computers not owned or administered by them, etc. At the end of the day employees will have to decide themselves whether a work account makes more sense for them or not.


Is anything in programming truly evil?

So, there are a bunch of questions appearing asking is X evil, is Y evil. My view is that there are no language constructs, algorithms or whatever which are evil, just ones which are badly used. Hell, if you look hard enough there are even valid uses of goto. So does absolute evil, that is something which is utterly incompatible with best practice in all instances, exist in programming? And if so what is it? Or is it just bad programmers not knowing when something is appropriate? Edit: To be clear, I'm not talking about things programmers do (such as not checking return codes or not using version control - they're choices made by bad programmers), I mean tools, languages, statements, whatever which are just bad...


What is the average lifespan of a cookie

I am wondering if there is any research on the lifespan of cookies on users computers? For a website I'm building we are looking at giving the users some personalization based on a previous selection when they come back at a later point. However, our users mostly will come back a few months or even a year later. Of course I can set the expiration time of the cookie to a year or longer. But overtime people get a new computer, a new install, or just a new browser (version). Or there might be other changes which make the cookie be deleted. I'm guess that the cookie won't survive the length of a year. Will it be worth saving this in a cookie? E.g., how much percentage of the cookies will still be there by that time?


Rewrote GNU GPL v2 code in another language: can I change a license?

I rewrote some parts of Mercurial (which is licensed under GNU GPL v2) in C#. Naturally, I looked a lot into original Python code and some parts are direct translations from Python to C#. Is is possible have "my code" licensed under different terms or to even make a part of a closed-source commercial application? If not, can I re-license "my- code" under LGPL, open-source it and _then_ use this open-sourced C# library in my closed-source commercial application?


What is the role of C++ today?

Currently I'm an IT student and I'm wondering what is still important in C++ today, what for is it used? I completed basic C++ course in my university but I can't imagine where can I use my knowledge and in which direction should I go learning C++. In other words what should I learn to become a successful C++ programmer? Currently I'm learning Java just because I don't see clearly in which area C++ could be useful today, but I clearly know which kind of work I'll be doing as a Java programmer. But I still hope that C++ isn't dead.


Should we push for more JavaScript on the JVM, alongside Java and Scala? Or, if not, why?

With JavaScript becoming one of the most widely used languages around, I began asking myself why people do not find ways to use it extensively on the JVM. As a programmer who spends half day writing Java, and the other half, writing JavaScript, I do see a lot of potential in this. Was it just the timing that shot Scala up straight? Or the nature of the language itself. Although JavaScript and Java are fundamentally different languages, it is certainly not a problem to compile JS to Java bytecode. That's what Rhino has been doing for many years, right? Or the maybe the problem lies in the performance? Whatever it is, I would be interested to know.


Should a c# dev switch to VB.net when the team language base is mixed?

I recently joined a new development team where the language preferences are mixed on the .net platform.               Dev 1: Knows VB.net, does not know c#     Dev 2: Knows VB.net, does not know c#     Dev 3: Knows c# and VB.net, prefers c#     Dev 4: Knows c# and VB6(VB.net should be pretty easy to pick up), prefers c#      It seems to me that the thought leaders in the .net space are c# devs almost universally. I also thought that some 3rd party tools didn't support VB.net but when I started looking into it I didn't find any good examples. I would prefer to get the whole team on c# but if there isn't any good reason to force the issue aside from preference then I don't think that is the right choice. Are there any reasons I should lead folks away from VB.net?


What best practices should be employed in a PHP login script?

I am wanting to re-write my login scripts for clients websites to make them more secure. I want to know what best practices I can implement into this. Password protected control panels are in their abundance, but very few seem to impliment best practices in terms of code writing, speed and security. I will be using PHP and a MYSQL database. I used to use md5, but I see that sha256 or sha512 would be better (together with secure hash and salt). Some login scripts log the ip address throughout the session or even the user agent, but I want to avoid that as it isn't compatible with proxy servers. I am also a little behind the best practice in using sessions in PHP 5 (last time I read up was PHP 4) so some best practices with this would be helpful. Thanks.


Is shipping a Clojure desktop app realistic?

I'm currently shipping a desktop Java application. It is a plain old Java 5 Java / Swing app and so far everything worked nicely. Java 5 was targetted because some users were on OS X version / computers that shall never have Java 6 (we may lift this limitation soon and switch to a newer Java and simply abandoning my users stuck with Java 5). I'm quickly getting up to speed with Clojure but I haven't really done lots of Clojure-to-Java and Java-to-Clojure yet and I was wondering if it was realistic to ship a Clojure desktop application instead of a Java application? The application I'm shipping is currently about 12 MB with all the _.jar_ so adding Clojure doesn't seen to be too much of an issue. My plan would be to have Clojure call Java APIs: my application is already divided in several independent jars. If I understand correctly calling Clojure from Java is harder than calling Java code from Clojure which is why I'd basically rewrite all the UI (part of the UI, mixing Swing components and self-made BufferedImages needs to be rewritten anyway due to the rise of retina display), and do all the 'wiring' from Clojure. So that's the problem I'm facing: is it realistic to ship a Clojure desktop app? (it certainly doesn't seem to be very widespread but then shipping plain Java desktop apps ain't that common either and I'm doing it anyway) Technically, what would need to be done? (compared to shipping a Java app)


C++ Typecasting VS performance

Let's say we're designing a video game. We have some sprites on the map and we want to call some method of the particular sprite at some particular position. We are using _one broadly-known C++ framework_. It has an `GraphicsItem` class, and ALL our sprites are derived from it. Now, framework has a method to get a pointer of the `GraphicsItem` at any position on the map. We've got two options now:   1. Cast from `GraphicsItem*` to our `Sprite*` and call `Sprite`'s method. (We know for sure that all the graphics items on the map are instances of `Sprite`)   2. _Make some crazy things like_ Store pointers to `Sprite` in some container, iterate through them, compare address vales and get straight `Sprite*` without casting. The question is: what is the best practice in this case? I was always told to avoid typecasting because it means you've got design issues. But how can I change design to avoid typecasting here? And extra iteration over a container with a comparison is just... crazy...


As a student, how to answer a random question: "Is 'something' about the topic unclear to you?"

While attempting to make a list programming subjects/topics that were unclear to me, I was unable to come up with anything. I know I can't be clear on everything. What steps can I take to get an accurate self-assessment of my knowledge and "know what I don't know"?


How to communicate with a co-worker that considers frameworks a performance hit

How can one sell an idea like "we should use jQuery because its highly optimized and cross browser compatible" or "entity framework is cool because its neat and takes care of our model automagically" when the common response is a blanketed statement such as "jquery doesn't perform well" or "entities bring in 12 columns on a table when we only need 10"? I am a pragmatic guy that tends to trust axioms I've developed through experience (its not a performance problem until there's a visible slowdown). I don't know if there's a specific "category" that the other extreme fits into, whereas everything is a performance problem until proven otherwise...or even where to begin the communication here.


Do you write unit testing or TDD as a line item requirement into your contracts or statements of work?

If you do, do you discuss coverage, continuous integration, quality control, or anything related to the difference between unit testing, functional testing and TDD in general? If clients ask, do you simply state that you will unit test, but leave out specifics?


What would motivate you to do free programming work for work after work?

I'm not talking about working overtime for a project, but R&D, or test bed applications that benefit the company. These would become teaching tools, and eventually sales tools. I know it sounds crazy to even ask, but I'm seeing a trend in this industry with regard to rapidly changing technology, and a problem with getting programmers to bring the after hours knowledge gained in house. You would think it would spill over naturally, but I find most leads holding back because the work would then be "managed" by the company, and now the property of the company. Are there solid programs or initiatives that stimulate a back-and-forth, where you can actually bring something to the table and be rewarded for it? **EDIT** Can anyone provide additional feedback on this: _Are there solid programs or initiatives that stimulate a back-and-forth, where you can actually bring something to the table and be rewarded for it?_ There appears to be a miscommunication here, where some users are under the impression I'm trying to figure out how to get free work out of colleagues. Just the opposite is true. I want to know if there are programs that exist, or ideas that you have that would motivate you, which doesn't necessarily have to be money.


How can I help open source win in the future against closed systems like iPhone and iPad?

I would like to donate a lot of my time over the next few years to helping open source hold its own against closed systems like the iPhone and iPad in the mobile and appliance computing space. If that's my goal, what's the better strategy -- to do development work for Android or for Ubuntu? I know Ubuntu is behind on the mobile front, but they work great on netbooks and are gradually moving into the tablet space. And there are questions over whether Android is really faithful to the spirit of open source. http://www.wired.com/epicenter/2010/10/is-android-open/ Any suggestions? I'm primarily a Ruby programmer who has done a lot of iOS programming.


gRaphael plugin best practices

I'm looking for best practices when creating a plugin for gRaphael. I'm looking for something like jquery where in its documentation you have the best practices of how to write a plugin. So far I haven't found nothing so I'm starting to imagine that it just comes down to best practices with javascript and not with a particular order of the code or configurability... any thoughts?


Should cases be reopened for bugs, or should bugs be opened as a new case?

Currently at my work place we use FogBugz for managing all our features and bugs for our different web applications. When a new feature is to be added to one of our web applications, a new Case is created. For example "Create CSV Upload Form". I then work on the case recording the amount of time I've spent on it. Once this case is completed, I then resolve it, and it gets assigned back to the case opener (usually the project manager), who then closes the case. If there are any bugs with the feature, my Project Manager then re-opens the case, and assigns it back to me with a bullet point list of bugs. In my opinion I believe these bullet pointed bugs should be opened as individual bug cases, so that they can be tracked easier, and not get cluttered with the original feature case notes. My managers disagree with me stating that it is easier to work out the total time spent on the feature if its all in one case. Furthermore they believe it is less confusing for our clients as they only have 1 case number reference for the feature. However I would stress that the bugs should be dealt with as seperate cases as this is post-completion of the original case. Am I right in stating that bugs should be reopened as a new case? And what are the pros/cons of each way of managing this?


Is it possible to use the framework behind Metro UI to make Exposé?

Is it possible to use the framework behind the Windows 8 Metro UI to make Exposé-like application for Windows? I tried Mac and I really like this feature, on another side i like that I can drag the screen from the top of the screen into the Metro UI, but that is completely useless. So imagine if it is possible to use this functionality in a Exposé-like application for windows. Is it even feasible? If not, maybe at a later stage? I am a programming rookie, but it could be a fun project. Thanks in advance for any answers, suggestions and information.


Can I use Visual Studio 2010 Architectural features to enforce design on code, without feature packs?

I am studying Visual Studio 2010's architectural tools for application lifecycle management. After we have sketched some modeling diagrams, we wonder now how should be the natural workflow to convert that to architecture-compliant code. We noticed that UML Explorer tab keeps track of entities created in class diagrams, sequence diagrams and component diagrams, but not so with layer diagrams and activity diagrams. The main problem is: when the modeling is ready, how would be the expected way to convert it to a compliant code? Possible paths could be:   * "you have to manually keep track of everything";   * "you can use feature X and/or technique Y";   * "There's no way to do that without the Modeling Feature Pack"; As far as I have researched until now, everything suggests that the Feature Pack is needed, but I wonder what would be the point to have those standard modeling projects if the greatest advantages of modeling (tracking and validating development code) cannot be performed... UPDATE: This blog post shows how to use Layers Diagram of a modeling project (via Validation flag on modeling project's properties tab) to RAISE BUILD ERRORS in case a layer dependency (which can be manually created) is violated. That seems promising, and I wonder which more of these hidden features the "non-feature-packed" Visual Studio 2010 might have. Thanks for any help


Is there a general method to evaluate the optimality of an optimization algorithm?

is there a general method to evaluate the optimality of an optimization algorithm, for example an algorithm solving an otherwise NP-hard or NP- complete problem? The only method I came up so far is comparing the results of the algorithm against already known optimal solutions. If not, are there specific methods for some special problems? **EDIT** To clarify: By optimality I mean how close the result is to an optimal solutions result.


What differentiates the exceptional programmers from the really good ones?

You know who they are. They are the rock stars of programming:   * They code 10X faster.   * Their code just works.   * They not only know their primary language inside and out, but they also know how it works under the hood.   * They know the answer to most any question before you ask it.   * A few of them invented the programming principles we all use.   * And they tend to be uncharacteristically humble, as well. What is it about these folks? Is there something about their thought process that is fundamentally different from the above-average programmer? Or are they simply very talented people that work hard? To put it another way: How can I be like them? I know what I think I need to learn to be that good, but it seems like it will take me the next ten years to learn it, and then my knowledge will be obsolete.


How to maintain lots of different variations for deployment, using Git for development

Although there are many similar questions here regarding using GIT for maintaining different versions, none seem to answer my specific case. I'm OK with how to use GIT to do my development, using different branches to do hot fixes, versioning etc. However, I am making a commercial application that needs to track various modules and configurations for **DIFFERENT** clients. And I do NOT wish the client to have access to a module or code they haven't paid for. Yet I would like to use GIT to deploy on their server, or to be able to deploy directly on the client server using ssh/rsync, or even on my server in a unique directory, then zip up the source files using a standard process. Let me give you an example: Client A:   * Deploy basic application   * Deploy Module A (e.g. forum) only   * Deploy Client A specific theme with Client A specific logo Client B:   * Deploy basic application   * Deploy Module A (e.g. forum)   * Deploy Module B (e.g. faq system)   * Deploy Client B specific theme with Client B specific logo Development Server:   * Contains basic application   * Contains Module A (e.g. forum)   * Contains Module B (e.g. faq system)   * Contains Client A and Client B themes with all logos   * Contains Development Notes which must NOT be visible to client   * Contains build files used with Phing - these must NOT be available to clients It's very important to understand that GIT on the development server contains proprietary data for Client A and Client B. Therefore Client A must never see my development notes, my Phing build files, Module B (faq system) or code/data/images for Client B. I do not need to keep variations of a module or the basic application for individual clients. Everything is standard across the system, and it's only the deployment configuration/variation for each client which is unique. I am happy to use GIT Submodules to keep some parts separate, if that helps. Note that all my code is in PHP and I am happy to deploy solutions using PHP, Perl, Python or scripting, but I don't want to use Java on the destination server. Ideally I would like to avoid Ruby solutions, if possible. I have access to SSH on the client server and can use rsync over SSH as well, but I need to be able to execute a script on the client server to clean caches etc after an update. My development machine is **Windows** \- yes, unfortunate, but true. If I cannot achieve what I need on Windows then I will run CentOS/Fedora in VMWare. This is not a multi-server deployment requiring simultaneous updating across a server farm, although it would be nice to be able push out updates of the application to all the various clients on a schedule or using a single command/procedure rather than having to do it manually for each one. I would also need to be able to push client specific updates to individual clients as and when required (for instance HTML or logo updates). So, can I use GIT for deployment, or at least track the various configurations using branches? Or is it simply going to be too messy? Can I hide Client B from Client A, including in commit history, in a particular branch, to make sure someone proficient with GIT at the client's organization cannot retrieve code they mustn't see (and this is a **contractual** requirement of the project)? If so, how do I do this in GIT? If not, how can I **best** manage a build process that allows me to deploy client specific configurations? Note that initially I will be managing around 20 different clients, and this might grow to 100 or more different configurations as each one will include their own HTML and logos, and a variation based on a potentially unique selection of 15-20 modules. I am happy to maintain a hundred different XML configuration files if that's what it takes. I am aware of Capistrano, but from reading about it, it doesn't seem that suitable for my specific case. If you feel otherwise, please do feel free to state so.


How much programming skill should I have as a computer security expert?

I have a fairly comprehensive understanding of a program environment (from machine to code), however I have limited experience actually programming anything. Is this something I really need to work on? or is conceptual understanding enough?


What are some effective ways of helping someone learn a programming language/framework in a focused way?

Here's some background:   * I have someone who is motivated to help me out on a project that already has a good chunk of code written   * The person does not have a CS background, but knows the basics (functions, variables, objects, classes, etc)   * The goal isn't to make this person a rockstar developer overnight - they just need to be able to pull their weight on this specific project.   * The project is a Rails project, but if there are general responses, I'd like to favor them. The current approach that is being taken is to give this person a simple feature (that has a similar feature already written). Then nudging them when they get confused, while trying not to give them full chunks of code. Regardless, they're very confused and frustrated, and moving slowly. Not unexpected, but I'm wondering if there are any tips or tricks to help them learn more effectively, and get to the wonderful "ah-ha!" moments.


Computer security expert using pre-made tools or own?

As a digital security consultant when is it 'ok' to use tools someone else made (dumb to reinvent the wheel, right?) and when should I make my own?


In a specification, should I describe what a product does (ideally) or what it should/must do?

I'm writting a German specification (I'm not German). Differences may appear for this process in different cultures, especially in the terminology, but usually here's the idea:   * The **client** writes his **needs and wishes** in a document, called a scope statement or **requirements document**.   * The **supplier** tries to understand the **actual need** of the client (which might be different to what was written _and_ to what the client meant to say _and_ to what the client _thinks_ he needs, etc.)   * The supplier writes a **specification** for the **product** , which should fill the client's need.   * The specification needs to be **precise enough for the product to be made** (ambiguity problems occur).   * The client and the supplier can check whether they have understood each other, and discuss details of the product.   * The client **agrees** with the specification (or at least its current iteration) and the supplier is ready to start the **work**. (it may of course be expected of you to disagree with this process, but this is irrelevant to my problem): I'm now somewhere around the last two steps and I've been criticized because I wrote what the product _must_ do, and not what it _will do_ ideally. Usually along the lines of > The product must be able to perform task A And I was expected to write > The product performs task A This is a simple word play, but I feel saying what the product _does_ , while the product isn't even on the way to be made yet, is wrong. I would tend to consider a specification as a contract of what the product is expected to do (what it must do and how it should do it), and not what it _does_. Said differently, I feel this is the specification and not the manual of the end product…… Should I say what the product _must do_ or what it _does_?


How are algorithms developed?

I'm impressed with the efficiency of some algorithms and I noticed the way the problem is solved can be and/or appear really unintuitive. It may sound dumb, but I would like to know:   * **How do the authors come up with amazing algorithms? Do they just keep thinking about the problem and end up with the answer? Are they geniuses?**   * Which leads me to my next question: **how long do they take to find the solution? Hours, days, months, years?** I know there isn't a definite answer to these questions. But I would like to know how it usually works regarding the most used/known algorithms.


Code review if nobody in team has knowledge in some technology?

Sample situation: A team of Java developers starts an iOS project. Only one developer has Objective-C/iOS knowledge, and in the beginning he will work on this project alone. How we can perform code reviews in this situation? What are processes, approaches, tools that this developer will use?


Java HTTP Header issue

I'm looking to download videos from YouTube. My code works I can save the videos no problem but for some videos an HTTP response code of 403 is returned. For example all Vevo videos return 403 errors. I'm pretty sure it is to do with the headers. I've added headers to the request as per Chromes Live HTTP Headers. This is my code. Can somebody please suggest something I'm missing.               Base url used = "https://www.youtube.com/watch?v=dvgZkm1xWPE";          String url = "http://r5---sn-8vq54voxpx-q0ce.googlevideo.com/videoplayback?mv=m&ratebypass=yes&sver=3&id=o-AG0Zbfjq6nIMbyri8B5-6_-C8Vc4WHeRLHXbmh6CLK2A&source=youtube&sparams=gcr,id,initcwndbps,ip,ipbits,itag,ratebypass,source,upn,expire&mm=31&expire=1408069579&key=yt5&mws=yes&fexp=901466,902408,927622,931983,934024,934030,946023,949402&ms=au&ipbits=0&initcwndbps=1059000&&mt=1408047855&gcr=ie&ip=109.79.21.79&upn=xEwXucfWzTk&type=video/mp4;+codecs=%22avc1.64001F,+mp4a.40.2%22&quality=hd720&itag=22&fallback_host=tc.v8.cache7.googlevideo.com&signature=8287AA736059404B5179505C650D2CE6145F988B2.3AD41A007E3A69ABED73FF1C1A957BE645BDCDBDDB5&";               CloseableHttpClient httpclient = HttpClients.createDefault();     HttpGet httpget = new HttpGet(url);     httpget.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36");     //httpget.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");     httpget.addHeader("Accept", "/");     httpget.addHeader("Accept-Encoding", "gzip,deflate,sdch");     httpget.addHeader("Accept-Language", "en-US,en;q=0.8");     httpget.addHeader("DNT", "1");     httpget.addHeader("Origin", "https://www.youtube.com");     httpget.addHeader("Referer", "https://www.youtube.com/watch?v=" + videoID);     httpget.addHeader("Connection", "keep-alive");          CloseableHttpResponse response = httpclient2.execute(httpget2);     HttpEntity entity = response2.getEntity();          System.out.println("\nResponse Code: " + response.getStatusLine().getStatusCode());     System.out.println(entity.getContentType());


Delegate pattern : Who has the responsability to create return Object?

I've a question about the Delegate Pattern : If I want to delegate the parsing of a xml file, for instance, that I want to be converted into a Key-value Dictionary. Let's take this classical example... What's the best practice about the creation of that Dictionary Object?   * Is it the "main" object that creates it and pass a reference to it to the delegate, asking him to fill it up,  or   * Is it the delegate that create this dictionary add pass it back to the "main" object, when he has done his job, trough the return value of the call-back method (or any other way) Is one of this two ways really better than the other ? And why ?


Is this a pattern? Should it be?

The following is more of a statement than a question - it describes something that may be a pattern. The question is: is this a known pattern? Or, if it's not, should it be? I've had a situation where I had to iterate over two dissimilar multi-layer data structures and copy information from one to the other. Depending on particular use case, I had around eight different kinds of layers, combined in about eight different combinations:               A-B-C     B-C     A-C     D-E     A-D-E      and so on After a few unsuccessful attempts to factor out the repetition of per-layer iteration code, I realized that the key difficulty in this refactoring was the fact that the bottom level needed access to data gathered at higher levels. To explicitly accommodate this requirement, I introduced `IterationContext` class with a number of `get()` and `set()` methods for accumulating the necessary information. In the end, I had the following class structure:               class Iterator {       virtual void iterateOver(const Structure &dataStructure1, IterationContext &ctx) const = 0;     };          class RecursingIterator : public Iterator {       RecursingIterator(const Iterator &below);     };               class IterateOverA : public RecursingIterator {       virtual void iterateOver(const Structure &dataStructure1, IterationContext &ctx) const {         // Iterate over members in dataStructure1           // locate corresponding item in dataStructure2 (passed via context)           // and set it in the context           // invoke the sub-iterator     };          class IterateOverB : public RecursingIterator {       virtual void iterateOver(const Structure &dataStructure1, IterationContext &ctx) const {         // iterate over members dataStructure2 (form context)           // set dataStructure2's item in the context           // locate corresponding item in dataStructure2 (passed via context)           // invoke the sub-iterator     };               void main()      {       class FinalCopy : public Iterator {           virtual void iterateOver(const Structure &dataStructure1, IterationContext &ctx) const {               // copy data from structure 1 to structure 2 in the context,               // using some data from higher levels as needed           }        }            IterationContext ctx(dateStructure2);       IterateOverA(IterateOverB(FinalCopy())).iterate(dataStructure1, ctx);     }      It so happens that dataStructure1 is a uniform data structure, similar to XML DOM in that respect, while dataStructure2 is a legacy data structure made of various `struct`s and arrays. This allows me to pass dataStructure1 outside of the context for convenience. In general, either side of the iteration or both sides may be passed via context, as convenient. The key situation points are:   * complicated code that needs to be invoked in "layers", with multiple combinations of layer types possible   * at the bottom layer, the information from top layers needs to be visible. The key implementation points are:   * use of context class to access the data from all levels of iteration   * complicated iteration code encapsulated in implementation of pure virtual function   * two interfaces - one aware of underlying iterator, one not aware of it.   * use of `const &` to simplify the usage syntax.


Good resources for language design

There are lots of books about good web design, UI design, etc. With the advent of Xtext, it's very simple to write your own language. What are good books and resources about language design? I'm not looking for a book about compiler building (like the dragon book) but something that answers:   * How to create a grammar that is forgiving (like adding optional trailing commas)?   * Which grammar patterns cause problems for users of a language?   * How create a compact grammar without introducing ambiguities. Here, think "clean language", not "parser builder warnings". Maybe "how do I avoid confusing the developer using my language?"


Common and frequently used algorithms of Data structures?

I have been programming for a while, and the edge that I am missing over other programming is algorithms. I know what is linked-list and binary tree, but I dont know many more of them. I failed on 2 interviews, because of exercises that demanded me to know some data structures algorithms. I am also starting to build a javascript project which has some heavy processing, and I need to know a few good frequently used algorithms?


Steps to Learn a Programming Language / Framework

I am new to programming. I am eager to learn new programming languages / frameworks. Can any one suggest the best way to master programming languages / frameworks?


Is this JS code a good way for defining class with private methods?

I was recently browsing a `open source` `JavaScript` project. The project is a straight port from another project in `C language`. It mostly use static methods, packed together in classes. Most classes are implemented using this pattern :               Foo = (function () {         var privateField = "bar";         var publicField = "bar";              function publicMethod()          {             console.log('this is public');         }                 function privateMethod()          {             console.log('this is private');         }              return {               publicMethod : publicMethod,                     publicField : publicField         };     })();      This was the first time I saw private methods implemented that way. I perfectly understand how it works, using a anonymous method. Here is my question : **is this pattern a good practice ?** What are the actual limitations or caveats ? Usually i declare my JavaScript classes like that :               Foo = new function () {         var privateField = "test";         this.publicField = "test";              this.publicMethod = function()         {             console.log('this method is public');             privateMethod();         }                 function privateMethod()         {             console.log('this method is private');         }            };      Other than syntax, is there any difference with the pattern show above ?


Where and when to include assets in languages that don't care where they are declared?

I come from c++, where one declares all assets to be included at the top of a file. That is what I have been doing with php as well. Lately I have been tempted to stray from this rule: I have a script file where I put functions I use throughout my projects, sort of like a library script. There are some functions included that require assets that no other function uses, and since one can put require_once statements all throughout one's scripts, I have been tempted to include assets at the beginning of those functions, to conserve resources when the script is running. Is this kind of thing frowned upon in OOP, or is that OK? I guess while I am at it, should I not be doing this at all because there is a purerer OOP approach to the kind of library scripts I have been creating?


Math library methods in Google's Go Programming Language

I have been programming in google Golang and have been enjoying it due to its brevity but I find it surprising that almost all its Math standard library methods are for the floating point type. Is there any particular reason why these methods do not exist for ints?


Should I perform encryption in the front end or within the database?

I want to store an encrypted string (specifically, email addresses) in a database. I'm currently using Python and MySQL. I was initially going to use MySQL's AES_ENCRYPT/DECRYPT to handle it, but then got to wondering if one was was better than another. It seems that if I tie it to a database function, that could potentially lock me into the database and at this point that selection may change down the road. Otherwise I would look to handling it in the Python code, but part of me thinks that having it all handled on the back end would free you to use whatever front end logic and code you wanted to. Any thoughts or ideas?


Ternary operator (condition ? foo : bar) and the XOR (^) operator

I have read in a recent code review that both `ternary operator (condition ? foo : bar)` and the `XOR operator ^` are rarely used in Java. Is it true? If yes, is this because they are less readable? or some other reason.


How image editing software change image contrast?

How Photoshop or other image editing software change an images contrast? What contrast mean when we process image pixel by pixel? Or what image contrast means? Here I created a very basic image to understand image contrast. This is a 10×10 pixels image that get a 100% non-legacy contrast adjustment in Photoshop. The only change I saw was in gray colors that were lighter after applying the contrast. Before and after contrast: ![The images before and after contrasts are similar, except for the gray color which is slightly lighter](http://i.stack.imgur.com/CqZhf.png)


How I can hide dependencies from my Services?

Here's a service abstraction that I am working on :               public abstract class Service     {     public ILogger Logger{get;set;}          public IQueryManager QueryManager{get;set;}          public ICommandManager  CommandManager{get;set;}     }      Then I have to call them in my class as usual :               Logger.Log("Something");          QueryManager.Query(new QueryObject()).Result;          etc.      But I'd like to have some protected helper methods to make these sentences less verbose :               Log("Something");\\calls Logger.Log("Something")          Query(new QueryObject()); \\ returns QueryManager(new QueryObject()).Result      Is there a way so that I can implement my dependencies so that they will be hidden from children of Service ? Is there an IoC container that allows me to use private properties to inject my dependencies ?


How to improve relationships between consultants and staff programmers

I have been a consultant for a small software consulting firm for quite some time now. Our normal business model is not staff augmentation, but such that we find clients who need assistance in building a solution of some kind and then send in a team who can build that solution, work with the existing IT staff, train all involved on supportting that solution, then move on to the next job. We, of course, are still around for any needed ongoing support. We have a great reputation in our area and have been very successful in implementing the solutions that we provide. However, I have noticed a common theme for most of our projects. When we get on-site, there is generally a "stressed" relationship between our team and many of the IT staff currently at the client. I understand completely that there may be some anxiety about our arrival and that defenses can come up when we are around. Many of the folks are understanding and easy to work with, but there are usually some who will not work well with us at all, and who can quickly become a project risk in many ways. We try to go in with open minds and good attitudes, and try NOT to be arrogent or condecending. We generally get deployed when there is a mess to clean up - but we understand that there were reasons decisions were made that got them in the bind they are...so we just try to determine the next step forward and move on. My question is this - I'd like to hear from the IT staff and programmers out there who have had consultants in - what are the things that consultants do that fire up negative feelings and attitudes? What can we do better to make the relationship better, not only in the beginning, but as the project moves forward?


The importance of Design Patterns with Javascript, NodeJs et al

With Javascript appearing to be the ubiquitous programming language of the web over the next few years, new frameworks popping up every five minutes and event driven programming taking a lead both server and client side: Do you as a Javascript developer consider the traditional Design Patterns as important or less important than they have been with other languages / environments?. Please name the top three design patterns you, as a Javascript developer use regularly and give an example of how they have helped in your Javascript development.


How do I distribute free copies of a paid iOS app?

Can anybody tell me how I can give my paid app a free download option to one of my friend from iTunes Connect. What I mean is that I will give my friend a code by which he can download my app without paying. Can anyone tell me if there is any option in iTunes Connect to do this?


Planning poker, individual or whole group in estimates?

In planning poker/scrum poker, when an estimate is made, should the estimate be made based on the assumption that only a single developer is assigned to that task, or a group of developers? If the latter, how large is that group? The reason this is relevant is that the time estimates would probably be different if a single person works on the problem compared to having several people. I've read several descriptions of how planning poker is supposed to work, but this basic information seems to be omitted, as if it should be inferred from the procedure in some way. In other words: If I give an estimate, should my estimate be how long I think a single developer in the group needs to spend to solve the problem, or how long the whole group would spend to solve the problem?


Is it bad programming practice to check if a class referenced by its interface is an instance of another class?

I have a class (`Timer`) with an array list of `Timable` objects. `Timeable` is an interface. There is some specific functionality that I need for the `Trigger` class (implements `Timable`), which has a reference called `target`. A lot of methods need to search through the `Timer` array for `Trigger` objects with a certain `target`. What I did was a function like this:               public Timable[] findObjectsWithTarget(Cue target) {         ArrayList<Timable> result = new ArrayList<Timable>();         for (Timable timed : fireable) { //fireable is the array (actually a HashSet) of Timed objects             if (timed instanceof Trigger && ((Trigger) timed).getTarget() == target)                 result.add(timed);         }         return (Timable[]) result.toArray();     }      This feels like a bad practice. The Timer class is now dependent on the Trigger class (sort of) and are no longer generalized. So, my two questions: **1) Is it actually a bad practice? Why or why not?** **2) What's a better way if it is a bad practice?**


Javascript library for Java source code reference

Could you suggest any JS lib, that will "recognize" all Java classes in specified text and create reference link to page with this class? (similar to Eclipse Ctrl+click) There are plenty of good JS libraries to highlight code, but none of them have this feature.


GCC vs clang/LLVM -- pros and cons of each

What are the pros and cons of GCC vs clang/LLVM?


How can I keep current with Python coding style?

I've been using Python since version 2.2. I do pick up new language constructs like for example `with` statement or dictionary/set comprehensions. However, I've realized that even though I'm being consistent with PEP-8, for existing constructs I'm using old style, rather than new style (for example `except Exception, e` instead of `except Exception as e`). Is there a resource which would have either most current style guide, or even better a list of changes in Python's coding style?


Kaizen in DevOps methodology?

I was wondering, Does anybody here works in a software development team under the DevOps methodology and applying Kaizen instead Lean for continuous improvement? I read that DevOps is based on Agile methodology and Lean, but I don't know whether it's possible to use Kaizen instead Lean. Thanks.


What is the process or term for viewing HTML/CSS using localhost?

I have recently used some software, which come as a regular setup file, where you install your software, and then when you run it, opens the browser, uses the localhost with some specific port number to connect to the software, and runs it from there. I find it quite useful and interesting. But I even don't know whether this kind of software and programming methodology have a name or not. Therefore, I would like to learn which programming languages, APIs, and frameworks are specifically designed for this purpose? One example to this is Metasploit. You can download its setup file, and install it casually like any other software, then when everything finishes, and you want to use the software. It will open the browser and connect to,               http://localhost:3790/      where Metasploit will load and start.


At what size of data does it become beneficial to move from SQL to NoSQL?

As a relational database programmer (most of the time), I read articles about how relational databases don't scale, and NoSQL solutions such as MongoDB do. As most of the databases I have developed so far have been small to mid scale, I have never had a problem that hasn't been solved by some indexing, query optimization or schema redesign. What sort of size would I expect to see MySQL struggling with. How many rows? (I know this is going to depend on the application, and type of data stored. the one that got me thing was basically a genetics database, so would have one main table, with 3 or 4 lookup tables. The main table will contain amongst other things, a chromosome reference, and a position coordinate. It will likely get queried for a number of entries between two potions on a chromosome, to see what is stored there).


What are the requirements for attribution in the MIT License?

choosealicense.com claims that the MIT license is “A permissive license that is short and to the point. It lets people do anything with your code **with proper attribution** and without warranty” (emphasis mine). Reading the license, though, I don’t see anything claiming that attribution to the original author has to be anywhere, so where are they taking that from?


PHP - PSR 0 - Configuration Constants

This question is about PSR-0 autoloaded libraries and the way main configuration constants should be declared and used. From your point of view (lib/framework developer), where/how should be declared your library configuration PHP constants (such as `ESCAPE_SOMETHING`, `USE_DOM`, `API_URL`, ...) in such a way that   * your code can easily address them   * client code can easily modify them depending on needs Is there any convention, recommendation, or even something I missed in PSR-0 I should be aware of?


Testing: Should I wrap system notifications and send my own?

In the current Cocoa app I'm working on, I've got an object, `RecordScheduler`, which responds to two types of notifications, "day did pass" and "quicksaving interval did pass". In both cases, the `RecordScheduler` tells a `Recorder` to do its recording job, among other things. Now I want `RecordScheduler` to issue a recording when the Mac goes to sleep. You subscribe to sleep/wake notifications via `NSWorkspace`:               [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self              selector:@selector(computerWillSleep:)              name:NSWorkspaceWillSleepNotification object:nil];      This is easy enough. Add it to `RecordScheduler`'s `-init` and the notifications would be processed just nicely. Thing is, for the other two cases I wrote helper methods like `fireDayDidPass()` to use in unit tests. I fired my custom notifications and added assertions for `RecordScheduler`'s response. Works well. I don't feel comfortable firing a `NSWorkspaceWillSleepNotification` since (a) it's not my own, and (b) I don't know about any side effects. Instead, I resorted to calling `[scheduler computerWillSleep:nil]` which would receive notifications. Now I don't have an intergration-ish test to verify `RecordScheduler` subscribes to `NSWorkspaceWillSleepNotification`. After I found out there is no additional information to be sent, I abandoned the idea of creating a `HibernationObserver` which subscribes to `NSWorkspace`'s notifications and re-sends my own kind of "Will Sleep" and "Did Wake" notifications. There seemed to be no additional benefit. Now here's the point:   * Is it still a unit test when I fire a notification and assert for both the side effects of notification handling and the receiver's subscription upon initialization?   * How else could I verify an object signs up itself as a notification receiver?   * Should I make it a habit to wrap system notifications in my own?


Is it bad practice to allow user defined fields?

Generally speaking, is it considered bad practice to allow for user created fields in a database for a webapp? For example, I am making a home inventory webapp for my wife, and she is going to want to define her own fields for different items. I was planning to allow her to create item categories, and add "features" to those categories. Features would just be key/value stored as strings. That way if she had a category called "Audio CDs" for example, she could add features for stuff like "artist", "tracks", etc. But in another category like "furniture", she could add features for stuff like "material" (wood, plastic, etc). Then any item could belong to one (or many) categories, adding those features to the item. I can see issues where searching by these features requires string comparisons, there's no validation of data, etc. Following agile methodology, maybe it would be better to just have her come up with new categories and attributes and I would just have to create new tables as we go. In my example, it's a small userbase (2 of us) and the amount of records created would be small, so not too bad. Generally speaking though, how do people handle something like this in "real life"?


Refactoring Switch Statements and is there any real use for Switch Statements at all?

I was reading this article and was wondering, do we get rid of all switch statements by replacing them with a Dictionary or a Factory so that there are no switch statements at all in my projects. Something did not quite add up. The question is, do switch statements have any real use or do we go ahead and replace them with either a dictionary or a factory method (in using a factory method, of course, there will be a minimum use of switch statements for creating the objects using the factory...but that is about it).


Is it possible to avoid enormously big switch in that case?

I'm writing a simple chess-related code with intention to write it clearly (performance doesn't matter at all). And this method I have doesn't look clean to me at all:                public static Piece GetClosestPiece(Square squareFrom, Direction direction)         {             //TODO: rework this mess             switch (direction)             {                 case Direction.Top:                     return                         _pieces.Where(p => p.Square.OnVerticalWith(squareFrom))                                .OrderBy(p => p.Square.Y)                                .First(p => p.Square.Y > squareFrom.Y);                 case Direction.Bottom:                     return                         _pieces.Where(p => p.Square.OnVerticalWith(squareFrom))                                .OrderByDescending(p => p.Square.Y)                                .First(p => p.Square.Y < squareFrom.Y);                 case Direction.Right:                 <...>                 case Direction.TopLeft:                     return                         _pieces.Where(p => p.Square.OnBackslashWith(squareFrom))                                .OrderByDescending(p => p.Square.X)                                .First(p => p.Square.X < squareFrom.X);                 default:                     throw new InvalidEnumArgumentException();             }         }      I store the pieces as list, so, here I'm using LINQ to find the piece closest to a given square on a given direction.   1. Do switch/if statements of this size (8 cases total here) always present a code smell?   2. Is there any way to refactor this part only, or should I consider reviewing the design of the whole solution?


Is it worth the time to run static analysis tools (e.g. Findbugs) on test classes?

How likely is it for a bug _that can be discovered by a static analysis tool_ (namely Findbugs) in _test classes_ mask a real bug in the actual code? Is this a realistic scenario? Is it really worth the time to run static analysis tools on them to find bugs in the actual code?


DDD with a 'School' domain

I've been asked to draw out the Bounded Contexts (BC) and the possible aggregate and the roots of a School domain. The domain consists of students who study modules on a course. The submit their assignment for a module which is then marked by an external tutor. The 'Marking' firstly sticks out as a BC, but im unsure about the rest... Also a 'module' would appear on multiple Bounded Contexts so how would i handle this?


How to make audio and video streaming servers work?

I am PHP MySQL developer and I am interested in the way television and radio are broadcasted over Internet live. I want to know how it works and and what are its requirements (which package of which programming language offers the best). And please clarify me: Websites are stored in servers. From my desktop, if I want to broadcast some video, then I need to connect to webserver (to upstream the video). Is there an application to do that (or do I have to code that or embed in my web application and which programming language would be suitable (does Python support that))? And I also need a script to handle the upstreamed video or audio (can I do that with PHP)?


PHP OOP: Should every object contain all the data?

I'm trying to learn PHP OOP "properly", and I was wondering, should the constructor grab all the information in the database and store it in the object? To use an example I'm trying to create using PHP OOP, an internet comic website (much like XKCD's), would have two classes:   * Catalogue (list and order of all the episodes)   * Episode (data relating to that particular episode) So, in this situation, should the `Catalogue` object get an array of all the episodeIDs (presumably this would be gotten in the constructor)? And if so, does that mean I have to update both the Object's array and the Database's array? And if so, what's the most common way of implementing this (presumably very common) action?


Why do javascript implementations parse numbers this way?

According to the ECMAScript spec the integer part of a decimal number should be either zero or start with a non-zero digit. A hexadecimal value should start with 0x. Javascript, in the major browsers, extends EMCAScript to include octal numbers. These are determined by having a sequence of digits (from 0 to 7 inclusive) start with a zero. Given these facts, my naive implementation of a javascript interpreter would probably parse integers a bit like this:               if first_char in [1-9] then         parse_input_as_decimal()     else if first_char is 0 then         if second_char is 'x' then             parse_input_as_hexadecimal()         else if second_char in [1-7] then             parse_input_as_octal()         else             parse_input_as_zero()      However the web browsers seem to act slightly weird in that if a number beginning with zero contains the digits 8 or 9 then it reads it as a valid decimal. This can lead to oddities, especially when using a decimal point or exponent. Some examples:               011 // is octal     0011 // is octal     019 // is decimal     0091 // is decimal     011.0 // throws an error     019.0 // is decimal     011e5 // throws an error     019e5 // is decimal      My question is why do they behave like this? Is it just some quirk of history? Or is there a good reason? Is it written in some spec somewhere? Will this ever change? I know this is a bit arcane and few people use octals in javascript these days, but I'm curious.


Functional testing before code checkin

I am working on a project with legacy code where it does not have much code coverage. One of the idea to improve that is to enforce a rule that each code check-in must have test, not only test but functional test as well, so that we can verify that the existing code did not break. I would like to get some ideas, both pros and cons on this approach. Sometimes it sounds like it's a huge undertaking as it will need a really good infrastructure so that developers can have their code fully tested before it is committed. How would one go about running automated unit tests as well as functional tests when code is checked in? Is this even a feasible idea?


Thoughts on a custom data structure for a node/chain implementation

I am designing a simple GUI that will allow a user to create a GPX route by clicking repeatedly on a map panel. I am faced with a design dilemma for how to represent the nodes and route. This construct can be abstracted as follows:   * the user clicks **n** times on the screen in sequence to create a chain of **n** nodes   * after a chain has been completed, a user can add more nodes to it, either by selecting nodes in the middle (inserting between existing nodes) or by simply automatically appending to the end with his next click At first I was determined to use a Java Collections class to represent the chain, but there are unexpected difficulties with that. On the surface, this would appear to be a perfect example of a `LinkedList`, but consider as follows. If the user wishes to insert a node in the middle of the chain, he first chooses some node on screen that he wishes to insert a new node before. If the node belongs to a linked list, it will need to maintain a reference to its encompassing list (a somewhat unusual practice, I'd think), and even then we will still have to locate the node in the list before we can insert. So we have to:   * find the node (linear time)   * insert the new node (constant time) Or if I try the same thing with an `ArrayList`, it also performs at best in linear time.   * find the node (linear time)   * insert the new node (linear time) But neither case really seems desirable. I briefly flirted with the idea of using a `LinkedHashSet`, but it does not allow insertion into the middle of the linked list, nor does it seem fundamentally correct to use a set implementation for something like this. So here is what I came up with:               class Node {         Node previous;         Node next;         Chain chain;     }      A Node maintains only a reference to its previous and next nodes, as well as the chain it belongs to (again, this latter part seems unconventional and possibly even wasteful to me, but I'm convinced it may be necessary here).               class Chain {         Node first;         Node last;     }      The chain knows only what its first and last nodes are. Now, if a user wants to insert a node in the middle of the chain? He selects the node, which simply updates the first/last references of itself and its neighbors. If he wants to add nodes to the end of a chain? He simply selects any node on screen (which is aware of what chain it belongs to, and therefore what the last node in that chain is), and the chain immediately begins updating link references for the last node and each node added after it, as well as keeping its own "last" reference up to date. I really wanted to use a Collections class, but this approach seems better to me. But I'd love to here thoughts/criticisms from more experienced programmers. Thanks.


What are the major challenges in creating a platform such as StackOverflow?

Let us assume you were to create a platform such as StackOverflow. It needs to be functional, fast and scalable, just like SO, in order to be successful. What are the major challenges you would face in such a task? I'm looking for technical challenges rather than problems such as how to advertise it and stuff like that. (I'm not looking for ways of creating a new site to challenge SO; I'm just interested in how difficult it would be to create it if it didn't already exist.)


Where can I learn and understand the complete workings of HTTP headers, so I can implement my own?

I am looking to learn how to properly use, and implement, HTTP headers. What is the best resource or set of guidelines that I can use? ( especially ranges to detect download managers, etc) ?


Is it legal/ethical to post production code?

This may sound silly or obvious but this is my case; I work at a company that recently implemented SAP and I was the responsible to generate/migrate the master data of the company which let me learn a lot from this system. SAP comes with its own language known as ABAP and since the system went live I've been learning and programming with it. Before ABAP I worked as a freelancer in other projects with VB6, VB.Net, C# and ASP.Net building a lot of stuff, here I've made some utilities that are been using daily, so I came with long experience in programming. At first ABAP was difficult but eventually after long analysis, googling and trial and error I became the guy who makes basically all the development in SAP from reports, to user-exits, enhancements, BADIs, tables, dynpros, etc. Daily I learn more and more because of all the requests I receive which makes me investigate and code a lot everyday. It has become challenging and funny at the same time. You could be very productive in ABAP once you get into. Ok, the question is - can I post how I resolved a certain thing in SAP? That implies that I'd publish production code. I feel doubtful about this.


Mediator vs Observer?

Can someone provide me with a canonical answer on the differences between an `Observer` and a `Mediator`, and a summary of when you should use one pattern over the other? I am unsure of what kind of situation would require an `Observer` and what kind would require a `Mediator`


How should I handle multi-tasking in a WPF application?

In most of the multi-tasking CRM applications I've seen, MdiWindow is used to allow users to open multiple windows at the same time. But MdiWindow doesn't seem to be commonly used in WPF. Looking through Codeplex, I only found one abandoned MdiWindow project. In some of the WPF-based CRM applications I've seen, they create a dashboard and only let users work on one thing at a time. What's the best way to handle multi-tasking in a WPF application? Is there a better alternative to MdiWindow in WPF?


If a dependency is not in the maven repository should I add it to source control?

One of the jar files that I use in my code is not in the maven repository(and yes I tried to avoid using it). I have installed it locally so when I build the project it gets picked up by maven. I also put instructions in my `README` so anyone who wants to build my code can see how to add the jar to their local repository. The question is, should I check this jar into my git source control? I know normally you don’t check jars into source when using maven and git but in this case it seems like it might be a better idea than saying, find this jar on the internet. I am the only developer in my group so setting up a company hosted repository for just this single jar is overkill.


Binding in web frameworks - to frontend data or backend data?

AngularJS and other web frameworks provide data binding abilities (as in WPF). Is the UI bound to JavaScript variables on the frontend (web browser) or is it bound to the data in the server (via AJAX and such)? I assumed that with all the MVC frameworks for the web, the model is the data on the server, the view is the web page on the client, and the controller is either on the server or on the client (browser). Did I get that wrong? I'm sorry if its a stupid question. I am a C#/C++ developer but with little experience in web development.


Structuring asynchronous javascript code

I am working on an application that heavily depends on asynchronous data operations. I am dealing with those through promises. However, while my code works, I have the feel that it is getting chaotic and hard to maintain in the future. Assume this:               validate().then(          // success     function(promise){         $http.post('stuff.php',data).then(                function(p){                },           function(){                }         )      },          // failure     function(reason){         // Assume another promise-depending operation     },          // notification     function(update){          }     );      As you can see, promise calls are heavily nested. Furthermore, I have to deal with resolve/reject methods in each and every step. What am I missing; how can I improve my technique?


Transition from maintenance programming to design

What to do people do develop a design for a s/w for a given set of requirements? I like many people joined a Semiconductor MNC and got stuck in maintenance for quite a couple of years. My work was usually changing a lines of code for windows drivers supplied by my company or a couple of small script (style like) C programs for validating h/w. As a result I developed the bad habit of 'programming by coincidence'. I have not developed the ability for designing tools/programs from scratch. I was the only s/w member of the local team and thus some grunt work from the well established other site of the company came to be done by me. Now I have moved to a different company and thus finding developing from scratch very difficult. How do I unlearn my bad habit and develop this ability of designing s/w and then coding it ?


What hurts maintainability?

For someone who doesn't have much real world experience yet, the notion of maintainable code is a bit vague, even though it follows from typical good practice rules. Intuitively I can tell that code can be well written, but not maintainable if for example it hard-wires information that is subject to constant change, but I still have a hard time looking at code and deciding if it's maintainable or not. So the question is: what hurts maintainability? What should I look for?


Mobile: Native vs. web - Input for discussion on top management level

I have been given the task of producing a compilation of pros, cons and key points on the issue of mobile native applications versus mobile web applications. It will be input for a discussion on top management level. What are some valid and maybe overlooked topics here?


Design Anti-Patterns - C# - Do you call this a God object?

I am writing Portfolio module for my web site and it has 3 components. Gallery Category, Gallery, & Gallery Images.   I am doing all the request handling, (creating, reading, updating, other), for the above 3 components in 1 class, Portfolio.   DB handling jobs for Portfolio module is done in another file.   My question is, even just for request handling purpose, can you do all the operations in 1 class? -Reddy


Is it misguided to label mobile web applications as cross platform?

Yes, you can access the mobile web site from a range different mobile devices, but the platform, I suppose, is still the web server and the client browser (the latter ideally being the "same" on any device). When talking mobile and cross platform I am thinking frameworks such as PhoneGap and Appcelerator Titanium, but still with a reluctance to call it cross platform as the deployed products are not the same. I guess I am hung up on the idea that it has to be directly equivalent to the Java virtual machine to call anything cross platform, but maybe I am the one who is misguided. What is the general opinion?


Advice on Switching Careers to Java Programmer

> **Possible Duplicate:**   >  Best way for a senior programmer to switch languages/environments in next > job? I have about 15 years of IT experience in IT Security and Networking. I am looking for a career change and I really would like to take a stab at Java programming. I have a CS degree but it's been about 5 years since my last class. I have intermediate experience in Perl (that is still current) and I am also trying to learn Python (although it has taken a back seat to Java). I picked up Sam's Teach Yourself Java in 24 Hours as a refresher to my Java classes I took in school. I am half way through it and luckily it's all coming back to me. I also have HTML and some SQL experience. The reason I chose Java and not Perl is because a.) I liked programming in Java in school and b.) Java seems to be in high demand these days. I wouldn't mind being a Perl programmer but it seems like all of the jobs have Perl listed as "nice to have" experience and not a requirement. I guess my question is what kind of jobs should I be applying for? I am thinking I only have enough knowledge for a beginner/intern type jobs but it's going to be almost impossible for me (personally) to take a job that only makes 1/3 of what I'm making now ($90k). Will I be laughed at if I attempt to apply for "real" programming jobs or is there such a demand for Java programmers now that someone will be willing to give me a chance? Thank you for any advice. I would really like to make this change within the next 6 months.


Why is it discouraged to create variables on the fly? PHP gives you a Notice Error

Are you guys familiar with those pesky PHP notice errors? You know, the ones that will appear when you do something like this:               if($some_variable == 45)      But if $some_variable wasn't created already, PHP will be like "Hey! Idiot! This variable wasn't defined yet!" and output a Notice Error onto the screen. However, you can simply turn PHP Notice Errors off by using error_reporting(0) and the application works perfectly. What's the point? Who cares if a variable wasn't created yet? Why can't you just create it on the fly inside the if statement? I feel like this is the easy, no-brainer way to do it, but apparently PHP discourages this practice. Why? What I find myself having to do a lot of times is something like this:               if(isset($some_variable) && $some_variable == 45)      If $some_variable is not set, the if statement automatically fails, so the second condition of the if statement is never checked, so the Notice Error never happens. This works great, but I feel like it shouldn't be necessary. Some of the applications I am working on are huge and I fear that the extra added conditions will slow down my poor old server if there are dozens of instances of it, combined with thousands of users. I know that this is just a single extra statement which would be O(1), which isn't a lot of resources, but it's still something I worry about. Should I not worry about O(1) even if I hypothetically were to have thousands of users? Am I caring too much about being efficient? I know PHP Notice errors can easily be turned off by using error_reporting(0). I'm not sure if certain types of errors can be turned on/off as desired because I haven't researched error_reporting() extensively. My question is what's the point? Why is it discouraged to create variables on the fly? I feel like creating variables on the fly may be a little bit lazier but is 10000000x easier to program and should be the no-brainer encouraged way to do it. This is meant to be both a philosophical and a technical question.


Is storing stack traces in database recommended?

The current system I am working on goes through a set of documents & performs some logic using the metadata of the document. If the metadata of a document is fishy..it throws an exception. The system logs the exception, fail the job & let the developer fix the issue by looking at logs before moving on. I want to improvise this system by making system fault tolerant as I have seen that generally the job fails because of few documents. System continues even if there's an exception raised. The exception information would be stored in the database table along with document information. This information would be sent to developer who can then work on fixing it without having customer waiting. The customer can later process those failed documents separately. My question is how to store the exception information in table. The exception would already be logged in the log file. One idea I was thinking was to store the time stamp of the exception so that developer can later find the time stamp in log file and understand the exception. But this comes with a possibility that the log files might be deleted. Does it make sense to store the entire stack trace in the database?


Is it reasonable for programmers to be sprinting the whole year round?

It feels like it is not enough for working programmers just to "walk" 5 to 8 hours a day, and "quick walk" is not enough, but they have to "sprint", every day, year after year. For the company, it makes a lot of sense because to get the most out of workers, sprinting all day long, day after day is better than people who merely walk the whole day. Here I am comparing our "sprints" to normal day life of walking vs sprinting. While we can sprint 100 meter a few times or even two dozen time a day, for a total of 15 seconds x 25, can anybody sprint the whole day long for 5 hours, and day after day? What I mean is, doesn't it make more sense to sprint for 3 months, and then get back to normal, when people can just "walk" or "quick walk", being productive, for the rest of the 9 months in a year? Or sprint for 3 months, get back to normal for 3 months, and then sprint for another 3 months and back to normal for another 3 months? It sure make a lot of sense to the company, because if people can sprint the whole year, then the company can get a lot of things done, burn out people, and just later replace the burned out people by other fresher people (possibly replaceable contractors) -- and it is such a nice term to use too -- we have people sprinting the whole year round -- we are getting the "maximum" output -- so the directors now can have reasons to get promoted to be vice presidents. I really wonder, should sprints really be year round? I think in the old days, when companies such as Microsoft made people work 60 hours per week, some people described them as a velvet sweat shop. But if we begin to say, we are just having sprints (and not mentioning that it is sprints for 3 weeks, and then another one immediately following, and it just repeats again and again the whole year round), then it sounds like a very justified thing to do.


How to integrate a second programmer to a startup

I'm the technical founder of a startup and I'm currently looking to hire a second developer for our product. Since I've been the sole developer, there is no formal organization for the project and I wanted to know what would be the minimum organization required to incorporate this second developer. Right now the code only under source control (a kind of chaotic git repo) but it lacks unit tests and other things that are required for serious development. I was willing to go without those for a while for the sake of speed, but now that the company is growing, we feel that delaying those might be problematic. How to incorporate this second person to work with the code?


Autocomplete seeding (with xml format?)

**Autocomplete driven development** is the issue. How do I feed autocomplete hints to IDEs, when I'm using scripting languages which provide magic methods? I'm not using an IDE usually. But it's obvious that many developers rely on them, and some percentage of them rely on autocomplete hints from the IDE. Now Eclipse and Netbeans both have support for PHP and Python. But they are of course unable to see class methods and attributes which are provided through `__get/__` or something. Whereas magic methods sometimes provide a nicer and more flexible API (and/or save coding). Anyway it's obviously an issue if you want to make the API visible to autocomplete programmers. So how can it be done? Is there an XML format for this? I know Eclipse is pretty xml-happy, but couldn't google up anything useful about that. How about Netbeans or other IDEs, is there any standardized scheme to signal autocomplete infos to code editors? (Would be nice if you could hobble in class methods and attributes, but also signal type hints for commonly used variable/object names.)


Switching between mobile webapp version using Ionic Framework and Desktop web app version?

I own a web application that make use of Twitter Bootstrap 3.   This eases the design of the mobile version since it brings some responsive features.   However, I would like a really native-mobile aspect for the mobile version, but not a native for the Desktop one.   I searched..and I found **this really promising framework** : Ionic It seems that this framework is really **only focused on Mobile application** and doesn't fit with any other kind of framework like Bootstrap (not mentioned in the documentation). Therefore, my questions are:   What should be the strategy to keep a desktop version (not using Ionic but bootstrap 3) and a mobile version using Ionic? Making two distinct UI applications? One that would use Bootstrap and the other Ionic? What about duplications??


Do preprocessor defines slow down build times?

I have a very large c++ project and I'm trying to decrease build times. I've been religious about forward declaring and only including files which are used. However I have many preprocessor defines which are setup in the project files (ie not in cpp or header files) so that I can keep them all in a central location for my different build configurations. Is it possible that this could increase build times? Would moving the preprocessor defines to a header file so they will only be included where needed speedup the build time? It seems like the build time would be faster if the preprocessor didn't need to scan and replace the defines for files that don't use any of them, but I'm not sure if it's worth the effort.


Handle complexity in large software projects

I am a lead developer in a larger software projects. From time to time its getting hard to handle the complexity within this project. E. g.   * Have the whole big picture in mind all the time   * Keeping track of the teammates work results   * Doing Code Reviews   * Supply management with information etc. Are there best practices/ time management techniques to handle these tasks? Are there any tools to support you having an overview?


Refactoring classes with ref to themselves

How can I refactor this code?               class Node     {        public Node Parent { get; set; }     }          class AVLNode     {        public AVLNode Parent { get; set; }     }      I tried to use inheritance, but then I have to use type casting:               class AVLNode : Node     {     }          class Program     {        void Main()        {           AVLNode a = new AVLNode();           AVLNode b = a.Parent **as AVLNode**;        }     }


Increase the size of a memory mapped file

I am maintaning a memory mapped file to store my tree like datastructure. When I'm updating the datastructure ,I got this problem. The file is limited on it's size and can't be too long or too small. I have a methods like                void mapfile_insert_record(RECORD* /* record*/);           void mapfile_modify_record(RECORD* /* record*/);      Both operations could lead to exceed the space which is free on memory file. How do I overcome this? What strategy I should use.   1. calculate whether it requires to exceed the file as a pre-condition on both methods.   2. Dynamically exceed it , for a example manage a timer and constantly polling file for it's free avaliable size and then automatically extend it. Any ideas or patterns to overcome this problem?


OO Design, how to model Tonal Harmony?

I have started to write a program in C++ 11 that would analyse chords, scales, and harmony. The biggest problem I am having in my design phase, is that the note 'C' is a note, a type of chord (Cmaj, Cmin, C7, etc), and a type of key (the key of Cmajor, Cminor). The same issue arises with intervals (minor 3rd, major 3rd). I am using a base class, Token, that is the base class for all 'symbols' in the program. so for example:               class Token {     public:         typedef shared_ptr<Token> pointer_type;         Token() {}         virtual ~Token() {}     };          class Command : public Token {     public:         Command() {}         pointer_type execute();     }          class Note : public Token;          class Triad : public Token; class MajorTriad : public Triad; // CMajorTriad, etc          class Key : public Token; class MinorKey : public Key; // Natural Minor, Harmonic minor,etc          class Scale : public Token;      As you can see, to create all the derived classes (CMajorTriad, C, CMajorScale, CMajorKey, etc) would quickly become ridiculously complex including all the other notes, as well as enharmonics. multiple inheritance would not work, ie:               class C : public Note, Triad, Key, Scale      class C, cannot be all of these things at the same time. It is contextual, also polymorphing with this will not work (how to determine which super methods to perform? calling every super class constructors should not happen here) Are there any design ideas or suggestions that people have to offer? I have not been able to find anything on google in regards to modelling tonal harmony from an OO perspective. There are just far too many relationships between all the concepts here.


How close have we gotten to automating code writing?

And I don't mean Autocomplete or automatic code snippets as inserted by modern day editors, or polymorphic code. But what is the state-of-the-art in programs that can go through given inputs and types and information of the desired outputs and output a valid piece of code in a language of choice. I am aware of Genetic Programming, Gene Expression Programming but I don't know of any other efforts. Also googling doesn't turn up much. Is anyone aware of any advancements on this front? Edit: When i say "output a valid piece of code", I mean an AI or something similar working out the logic and the flow of control and implement it in an imperative language. Imperative language only, since that's the tough part. Nevertheless, if you know of any new languages being developed to support this kind of idea, please do mention, as maybe our current set of languages are not suitable for the kind of early AI we may first chance upon.


I want to sell my application in Google Play Store, but I want the code to be open-source. Which license should I use?

I would like to sell the compiled binary of my android application in the Google Play Store when it reaches production. Which license can I use to prevent people from downloading my source code from the open-source page and selling an exact copy of my work on the play store? I want the code to be free and open for geeks/hackers to download and play with, but I don't want people who check out my source code to have the ability to use it for commercial use.


Inspiring People

So I work with a few people that I feel are intelligent but don't seem to be working out well. After working with them for a while I have seen the flashes of brilliance but mostly I see a reliance on others. What I mean by this is that most times it seems like at the first moment of trouble they go ask for help. Now personally I am all for helping and spend a significant portion of time helping others with whatever they need, but after helping others for so long I have noticed a disturbing trend. These people seem terrified that they might make a mistake and because of this they don't try. So my question is how can I motivate someone who is afraid of making a mistake? In my career I have always learned the most by making mistakes and learning from them. Personally I feel that if I hadn't learned so much I would never have made it as far as I have. So how can I get them to discover that they have the ability to figure it out themselves and that if they make a mistake and learn from it they will be better off. I feel that if I can discover some way to properly motivate them that we all will be better off.


Why is C# ASP.NET generally not regarded as a rapid web development framework?

The terms rapid web development gets associated with Python/Django and ROR. Why is this not the case with C# ASP.NET?


Is it right to appraise Scrum members according to number of successful user stories completed?

When my Manager told to team that " ** _now onwards successful user stories will be considered for appraisal!_** " We sat there for while shocked and that was one of the several jaw dropping moments he gave us :-) We felt that was stupid idea, since this will ruin all concept and goal of agile development methodology. Let me know what you people think? and how can we convince him?


Common Qt Producer/Consumer Example: What is the point of multithreading here?

While trying to figure out how to implement a Producer/Consumer Queue in Qt, I stumpled upon several SO answers, blogs and sites linking to this site: You're doing it wrong... I got the point of this site, but people are usually referring to the code example which is in the referenced blog: Threading without the headache The blog has a small code example attached, the core of it being posted by KornP in this SO answer: Qt moveToThread() vs calling new thread when do we use each So if you take a closer look we have the following behaviour:   1. Producer P produces an item, while Consumer C waits for events to appear in its event loop.   2. P forwards the produced data through a signal and returns to event loop idling.   3. C receives the signal in its event loop and consumes the data.   4. C emits a signal to the producer thread and returns to event loop idling.   5. Start over from 1. In other words: while P is producing, C does nothing and while C is producing, P does nothing. What is the point of having a producer and consumer **like this** in two different threads?   Wouldn't a single thread accomplish exactly the same?


Early attempt to remove Python GIL resulted in bad performance: Why?

**This post** from Python creator, Guido Van Rossum, mentions an early attempt to remove the GIL from Python: > This has been tried before, with disappointing results, which is why I'm > reluctant to put much effort into it myself. In 1999 Greg Stein (with Mark > Hammond?) produced a fork of Python (1.5 I believe) that removed the GIL, > replacing it with fine-grained locks on all mutable data structures. He also > submitted patches that removed many of the reliances on global mutable data > structures, which I accepted. However, after benchmarking, it was shown that > even on the platform with the fastest locking primitive (Windows at the > time) it slowed down single-threaded execution nearly two-fold, meaning that > on two CPUs, you could get just a little more work done without the GIL than > on a single CPU with the GIL. This wasn't enough, and Greg's patch > disappeared into oblivion. (See Greg's writeup on the performance.) I can hardly argue with the actual results, but I really wonder why this happened. Presumably, the main reason that removing the GIL from CPython is so difficult is because of the reference counting memory management system. A typical Python program will call **`Py_INCREF`** and **`Py_DECREF`** thousands or millions of times, making it a key contention point if we were to wrap locks around it. But, I don't understand why adding atomic primitives would slow down a _single_ threaded program. Suppose we just modified CPython so that the refcount variable in each Python object was an atomic primitive. And then we just do an atomic increment (fetch-and-add instruction) when we need to increment the reference count. This would make Python reference counting thread-safe, and shouldn't have any performance penalty on a single-threaded application, because there would be no lock contention. But alas, many people who are smarter than me have tried and failed, so obviously I'm missing something here. What is wrong with the way I'm looking at this problem?


Coarse grained remote interface vs encapsulating business logic

I'm writing a Web Service that will be consumed by a Mobile client. The Mobile client has to make several chained requirements checks to determine whether the user may initiate a request, and if so what type. If any of the checks fail then the user is redirected to a UI explaining why. I can't decide whether I should expose an operation for each check on my Web Service, or expose a single coarse-grained interface that simply returns all the check value results in a single DTO. Is the coarse-grained interface premature optimisation? I can always provide both the fine-grained and coarse-grained interfaces because the coarse-grained interface will use the local fine-grained methods to build its DTO.


What is your experience working for IT outsourcing company in the professional sevices and/or managed services?

I am from the UK. I have about 4 years experience working for a large European IT outsourcing company. This company was split into two; professional service and managed service. I only worked in the managed services and there was a lot of resources issues concerning reaching customer's expectation and there was a lot of conflict priority. I didn't enjoy may experience as a lot of arguments were involved with all internal parties and conflict of interest with external customers, legal matters etc. I do think now that perhaps, as a employee, I do not want to work in IT outsourcing company and just work for a company that handle its own IT services. I am wondering what has your experience been like? Are you or have you worked in the professional services or managed services? what was your experience like? Have you worked in both services and what is your preference? Look forward to your responses.


Running SQL Server Express on Micro/Extra Small VM

I'm exploring options for running a small cloud Windows Server (either AWS EC2 Micro or Azure Extra Small). The server won't be hit very hard, but I need to run a simple relational database, which I'm expecting to be moderately sized - probably a few tables with a few hundred thousand records, and running a few thousand queries a day to aggregate the data. I'm most familiar with SQL Server, so I'm looking into using SQL Express. However, the system specs are well below the recommended values for SQL 2012 Express. 2008 is a little better, but still not great. Anyone have experience (good or bad) with running SQL Server Express on one of these servers? I'll definitely do some testing before making a decision, but with the inconsistency that comes with these shared computing solutions, I can't be confident after just one or two testing sessions, so anecdotal evidence would be great. If SQL Server doesn't work well, I'll be looking into other solutions - it seems Postgres works well in a wimpy server, or maybe MySQL or one of its forks, or possibly cloud database hosting like Azure SQL Databases.


how to manage new private variables introduced into class?

Whenever I want to add a new functionality, I introduce a new private variable into the class. Declare it just above the first method definition. leave a small comment. Set it in a certain method. And then use this set value in another method. Now the possible problems which arise are, I dont cover all the possible cases when to modify the value of this variable and only notice a bug in it when during trying various possible user flows of the software. Is there any possible way to tie this value to some kinds of triggers so that I know all the possible situations when to modify its value? I am using Javascript. For e.g. I create a status message for editing an existing DB record. If the updating is failed over REST HTTP I set the status. Now I forgot to reset the status when I dont hit update button and instead select another record for updating. What is the best way to manage such new private variables? How to mange their state? what is the best software engineering way to prevent such mistakes?


Implementing the transport layer for a SIP UAC

I have a somewhat simple, but specific, question about implementing the transport layer for a SIP UAC. Do I expect the response to a request on the same socket that I sent the request on, or do I let the UDP or TCP listener pick up the response and then route it to the correct transaction from there? The RFC does not seem to say anything on the matter. It seems that especially using UDP, which is connection-less, that I should just let the listeners pick up the response, but that seems sort of counter intuitive. Particularly, I have seen plenty of UAC implementations which do not depend on having a Listener in the transport layer. Also, most implementations I have looked at do not have the UAS receiving loop responding on the socket at all. This would tend to indicate that the client should not be expecting a reply on the socket that it sent the request on. For clarification: Suppose my transport layer consists of the following elements:               TCPClient (Sends Requests for a UAC via TCP)     UDPClient (Sends Requests for a UAC vid UDP)     TCPSever (Loop receiving Requests and dispatching to transaction layer via TCP)     UDPServer (Loop receiving Requests and dispatching to transaction layer via UDP)      Obviously, the *Client sends my Requests. The question is, what receives the Response? The *Client waiting on a recv or recvfrom call on the socket it used to send the request, or the *Server? Conversely, the *Server receives my requests, What sends the Response? The *Client? doesn't this break the roles of each member a bit? **Update** I did a packet capture on an SIP Invite transaction between Ekiga and a PolyCom server. Ekiga was the client, and the polycom was the server. In the invite request Ekiga used port 5060 in the via header. 5060 is the port that its UAS is listening on, so that would seem to indicate that the UDPServer is receiving the responses to all requests and not the UDPClient that sent the request. Is this valid reasoning?


How to Get Myself Up to Speed in Building a Java Web App

I'm a new developer at a fairly large company and I'm working on a Java Web Application with a senior developer there. The Web App is built on top of an IBM stack (RAD, DB2, WebSphere) and basically uses JSPs and Servlets. The Web App is an internal tool to be used by employees to manage data coming from Excel files. So, there are lots of database interaction going around like SQL commands. My question is: I don't know much about JavaEE as a whole and only know a little about JSPs and Servlets and I would like to get myself up to speed so I can understand and contribute to the Web App as fast as I could. What resources (tutorials, links, etc) should I be looking at? Am I supposed to get a book about JavaEE or something that focuses just on JSPs and Servlets? EDIT: What I know well that I think is relevant:   * Java SE   * Object Oriented Concepts   * Some JSP & Servlets I just graduated from college so I don't have a really wide knowledge of frameworks and such yet but I spend a lot of time reading blogs and working on some small programs (not necessarily Java, more Python really.)