I should have used a factory method instead of a constructor. Can I change that and still be backwards-compatible?

**The problem** Let's say I have a class called `DataSource` which provides a `ReadData` method (and maybe others, but let's keep things simple) to read data from an `.mdb` file:               var source = new DataSource("myFile.mdb");     var data = source.ReadData();      A few years later, I decide that I want to be able to support `.xml` files in addition to `.mdb` files as data sources. The implementation for "reading data" is quite different for `.xml` and `.mdb` files; thus, if I were to design the system from scratch, I'd define it like this:               abstract class DataSource {         abstract Data ReadData();         static DataSource OpenDataSource(string fileName) {             // return MdbDataSource or XmlDataSource, as appropriate         }     }          class MdbDataSource : DataSource {         override Data ReadData() { /* implementation 1 */ }     }          class XmlDataSource : DataSource {         override Data ReadData() { /* implementation 2 */ }     }      Great, a perfect implementation of the Factory method pattern. Unfortunately, `DataSource` is located in a library and refactoring the code like this would break all existing calls of               var source = new DataSource("myFile.mdb");      in the various clients using the library. Woe is me, why didn't I use a factory method in the first place? * * * **Solutions** These are the solutions I could come up with:   1. Make the DataSource constructor return a subtype (`MdbDataSource` or `XmlDataSource`). That would solve all my problems. Unfortunately, C# does not support that.   2. Use different names:              abstract class DataSourceBase { ... }    // corresponds to DataSource in the example above          class DataSource : DataSourceBase {      // corresponds to MdbDataSource in the example above         [Obsolete("New code should use DataSourceBase.OpenDataSource instead")]         DataSource(string fileName) { ... }         ...     }          class XmlDataSource : DataSourceBase { ... }      That's what I ended up using since it keeps the code backwards-compatible (i.e. calls to `new DataSource("myFile.mdb")` still work). Drawback: The names are not as descriptive as they should be.   3. Make `DataSource` a "wrapper" for the real implementation:              class DataSource {         private DataSourceImpl impl;              DataSource(string fileName) {             impl = ... ? new MdbDataSourceImpl(fileName) : new XmlDataSourceImpl(fileName);         }              Data ReadData() {             return impl.ReadData();         }              abstract private class DataSourceImpl { ... }         private class MdbDataSourceImpl : DataSourceImpl { ... }         private class XmlDataSourceImpl : DataSourceImpl { ... }     }      Drawback: _Every_ data source method (such as `ReadData`) must be routed by boilerplate code. I don't like boilerplate code. It's redundant and clutters the code. Is there any _elegant_ solution that I have missed?


How can I multiprocess my program?

I wrote a program which scrape internet sites. It is pretty straigtforward because it process link one by one. With the limiting factor of the internet speed, the process is rather slow. I wonder, how can I make it multiprocess? The modules of python is confusing. I don't know the difference between subprocess and multiprocess. I've heard that multiprocessing is difficult and ineffective because of the GIL since python 2.x. I am using Python 3.2, so I wonder if things have been improved.


Help with DB Structure, vOD site

I have a video on demand style site that hosts _series_ of videos under different _modules_. However with the way I have designed the database it is proving to be very slow. I have asked this question before and someone suggested indexing, but i cannot seem to get my head around it. But I would like someone to help with the structure of the database here to see if it can be improved. The core table is Videos:               ID       bigint(20) (primary key, auto-increment)     pID      text        airdate  text        title    text        subject  mediumtext     url      mediumtext     mID      int(11)     vID      int(11)         sID      int(11)      pID is a unique 5 digit string to each video that is a shorthand identifier. Airdate is the TS, (stored in text format, right there maybe I should change that to TIMESTAMP AUTO UPDATE), title is self explanatory, subject is self explanatory, url is the hard link on the site to the video, mID is joined to another table for the module title, vID is joined to another table for the language of the video, (english, russian, etc) and sID is the summary for the module, a paragraph stored in an external database. The slowest part of the website is the logging part of it. I store the data in another table called 'Hits':               id      mediumint(10)   (primary key, auto-increment)     progID  text     ts      int(10)      Again, here (this was all made a while ago) but my Timestamp (ts) is an INT instead of ON UPDATE CURRENT TIMESTAMP, which I guess it should be. However This table is now 47,492 rows long and the script that I wrote to process it is very very slow, so slow in fact that it times out. A row is added to this table each time a user clicks 'Play' on the website and then so the progID is the same as the pID, and it logs the php time() timestamp in `ts`. Basically I load the entire database of 'Hits' into an array and count the hits in each day using the TS column. I am guessing (i'm quite slow at all this, but I had no idea this would happen when I built the thing) that this is possibly the worst way to go about this. So my questions are as follows:   1. Is there a better way of structuring the 'Videos' table, is so, what do you suggest?   2. Is there a better way of structuring 'hits', if so, please help/tell me! Or is it the fact that my tables are fine and the PHP coding is crappy?


The problems with Avoiding Smurf Naming classes with namespaces

I pulled the term smurf naming from here (number 21). To save anyone not familiar the trouble, Smurf naming is the act of prefixing a bunch of related classes, variables, etc with a common prefix so you end up with "a SmurfAccountView passes a SmurfAccountDTO to the SmurfAccountController", etc. The solution I've generally heard to this is to make a smurf namespace and drop the smurf prefixes. This has generally served me well, but I'm running into two problems.   1. I'm working with a library with a `Configuration` class. It could have been called `WartmongerConfiguration` but it's in the Wartmonger namespace, so it's just called `Configuration`. I likewise have a `Configuration` class which could be called `SmurfConfiguration`, but it is in the Smurf namespace so that would be redundant. There are places in my code where `Smurf.Configuration` appears alongside `Wartmonger.Configuration` and typing out fully qualified names is clunky and makes the code less readable. It would be nicer to deal with a `SmurfConfiguration` and (if it was my code and not a library) `WartmongerConfiguration`.   2. I have a class called `Service` in my Smurf namespace which could have been called `SmurfService`. `Service` is a facade on top of a complex Smurf library which runs Smurf jobs. `SmurfService` seems like a better name because `Service` without the Smurf prefix is so incredibly generic. I can accept that `SmurfService` was already a generic, useless name and taking away smurf merely made this more apparent. But it could have been named `Runner`, `Launcher`, etc and it would still "feel better" to me as `SmurfLauncher` because I don't know what a `Launcher` does, but I know what a `SmurfLauncher` does. You could argue that what a `Smurf.Launcher` does should be just as apparent as a `Smurf.SmurfLauncher`, but I could see `Smurf.Launcher being some kind of class related to setup rather than a class that launches smurfs. If there is an open and shut way to deal with either of these that would be great. If not, what are some common practices to mitigate their annoyance?


Why are F# exceptions generally not suffixed with 'Exception'?

In .NET, it is idiomatic to suffix exception types with `Exception`. But most, if not all, sources I have seen for custom exception types in F# don't follow this idiom. Most seem to use the suffix `Error`. From F# For Fun and Profit               exception MyFSharpError1 of string     exception MyFSharpError2 of string * int      From Microsoft Documentation*               exception MyError of string      The book 'Expert F# 3.0', co-authored by Don Syme, has an example that doesn't even seem to follow any idiom:               exception BlockedURL of string      Why don't custom exceptions in F# follow the standard idioms for .NET? Is it because of the OCaml heritage? * Link is to Google cache, as I cannot connect to MS at the time of writing.


What is the difference, between a server and a mainframe?

To me, it seems as though "mainframe" is a somewhat dated term; is it simply an older synonym of "server," or does it server a purpose more similar to a cluster/supercomputer?


What is a good technique to prevent unauthenticated users from accessing controller methods?

I have an event(s) controller:               class Event extends CI_Controller{             public function index(){        }             public function foo(){        }             //Shouldn't be able to use this method unless logged in        public function bar(){        }               }      And I'm trying to organise my code so it's fairly tidy and straightforward. Just now I have a controller named `MY_Controller` so that only authenticated users can access the methods(`edit_event()`,`add_event()`) of any controllers extending it. However, some of the methods in my controller need to be accessed by unauthenticated users (such as `get_event()`). What is a good way of handling this? Should I make two completely separate controllers or extend from the basic event controller and add authenticated methods? Previously I've had a manager controller that handled all methods which required authentication such as `add_user`,`delete_user`,`add_doc`,`delete_doc`. But it became blotted very quickly and wasn't easy to update or modify the controller (plus it was messy and didn't seem to follow good programming etiquette).


Converting a user management system to use ajax

I am currently building a website, which until quite recently was purely PHP. However I am now making trying to have the site use more AJAX, to lessen the page reloads. In PHP I had a lovely object orientated user class with methods for updating data, logging out, and so on. When a user logs on this would be stored as a session variable, and then any page that wishes to do anything the user could just grab it from the session and call it's methods. Clearly this use of php objects and the session doesn't really work with ajax. However I don't want to have to scrap storing the user in an object (which neatens things up somewhat), so don't just want to go down the route of defining a ton of js functions that grab the current username, and use the to do mysql queries through ajax. Am I being stupid here, and what route would people recommend I take.


Who Owns an Idea on the Web?

Let us say that person "A" mentioned an idea for a software project on the web (ie. in a forum). Person "B" sees this idea and implements it. Can person "A" claim ownership of the idea? Has person "B" done something illegal by implementing the idea that person "A" posted?


TDD in JavaScript

I'm about to participate in a Coding Kata and I would like to do it in JavaScript. What tools and libraries do I need for TDD in JavaScript?


Strategy for avoiding duplicate object ids for data shared across devices using iCloud

I have a data intensive iOS app that is not using CoreData nor does it support iCloud synching (yet). All of my objects are created with unique keys. I use a simple `long long` initialized with the current time. Then as I need a new key I increment the value by 1. This has all worked well for a few years with the app running isolated on a single device. Now I want to add support for automatic data sync across devices using iCloud. As my app is written, there is the possibility that two objects created on two different devices could end up with the same key. I need to avoid this possibility. I'm looking for ideas for solving this issue. I have a few requirements that the solution must meet: 1) The key needs to remain a single integral data type. Converting all existing keys to a compound key or to a string or other type would affect the entire code base and likely result in more bugs than it's worth. 2) The solution can't depend on an Internet connection. A user must be able to run the app and add data even with no Internet connection. The data should still resolve properly later when the data syncs through iCloud once a connection is available. I'll accept one exception to this rule. If no other option is available, I may be open to requiring an Internet connection the first time the app's data is initialized. One idea I have been toying around with in my head is logically splitting the integer key into two parts. The high 4 or 5 bits could be used as some sort of device id while the rest represents the actual key. The fuzzy part is figuring out how to come up with non-conflicting device ids that fit in a few bits. This should be viable since I don't need to deal will millions of devices. I just need to deal with the few devices that would be shared by a given iCloud account. I'm open to suggestions. Thanks. Update: After giving this some more thought, I've decided to take the short term hit and do this the right way. Using a GUID is definitely the best long term option for this. Using this approach eliminates the need to do any of the various options to deal with handing out key ranges or translating keys once an Internet connection is made. My original requirement prevented the GUID option because neither SQLite nor iOS support a simple, 128-bit integer type. Since I have a large existing code base that is written such that my keys are simple integer types, it will require a major refactoring of both the code and the database schema. In the end, I've decided that the short term pain of doing this refactoring out weighs the long term issues of dealing with a klunky solution. Taking the hit now gives me a much simpler and less error prone solution that will last the long term.


How to add precedence to LALR parser like in YACC?

_Please note, I am asking about writing LALR parser, **not** writing rules for LALR parser._ ## What I need is... **...to mimic YACC precedence definitions. I don't know how it is implemented, and below I describe what I've done and read so far.** * * * For now I have basic LALR parser written. Next step -- adding precedence, so `2+3*4` could be parsed as `2+(3*4)`. I've read about precedence parsers, however I don't see how to fit such model into LALR. I don't understand two points:   * how to compute when insert parenthesis generator   * how to compute how many parenthesis the generator should create I insert generators when the symbols is taken from input and put at the stack, right? So let's say I have something like this (`|` denotes boundary between stack and input):   1. `ID = 5 | + ...`, at this point I add open, so it gives   2. `ID = < 5 | + ...`, then I read more input    3. `ID = < 5 + | 5 ...` and more    4. `ID = < 5 + 5 | ; ...` and more    5. `ID = < 5 + 5 ; | ...` At this point I should have several reduce moves in normal LALR, but the open parenthesis does not match so I continue reading more input. Which does not make sense. So this was **when** problem. And about **count** , let's say I have such data `< 2 + < 3 * 4 >`. As human I can see that the last generator should create 2 parenthesis, but how to compute this? After all there could be two scenarios:   * `( 2 + ( 3 *4 ))` \-- parenthesis is used to show the outcome of generator   * or `(2 + (( 3 * 4 ) ^ 5)` because there was more input Please note that in both cases before 3 was open generator, and after 4 there was close generator. However in both cases, after reading `4` I have to reduce, so I have to know what generator "creates".


header file to convert speech to text

I'm doing a project on speech to text with omap processor in utlp kit. There is an API to record my voice and it converts my voice to pcm and is stored in a buffer. I have a few English words which I've recorded and converted into an array now I wanted to know how to compare the spoken word in the form of pcm with the array I have created. Or is there any header file or is it possible to `cprint` the pcm as a text.


initializer_list combined with other parameters

Suppose I have a class which takes a parameter of type `T` and a collection of parameters of type `U` in the constructor. The following solution works:               struct Q     {         Q(T t, std::initializer_list<U> us);     };      Creating an instance of this class would then be: `Q q {t1, {u1, u2, u3, u4} };` But this looks kind of unclean to me. Is there a better solution than this one?


Is good Grammar a prerequisite for your development team?

I understand that this may be primarily opinion based, but I also think it is an interesting question and would like to hear others' viewpoints on the subject. I recently became the senior developer for a large company, and inherited what I can only describe as a less-than-adequate code-base. Whilst I won't go in to detail as to why most of it was terrible, something that _did_ stand out, was the huge amount of spelling errors. One of the more notable ones, was "Actual" spelled "Acutal". This was pervasive in functions, classes, stored procedure names, and column names. To me, this is a clear indication of lack of care and due diligence with respect to ones' work. I believe that if code is littered with these kind of things, the programmer in question is not paying attention. I understand there is a caveat if the programmer in question is perhaps not a native-English speaker (in this case, they were) - but simple code reviews should pick these things up. As developers, we spend a lot of time making sure that our work is functionally correct, optimal without over-optimising, and finally - easy for another person to pick up and work with. Code that is littered with spelling errors is a sign (given the caveat mentioned above), that the programmer is not paying attention and that those errors might also indicate a lack of understanding of the problem being _solved_. Much the same way that any spelling errors on a CV is an instant red-flag situation. What do you guys think of this? Should we be bothered about English grammar within the code-base? Does it matter? Is it indicative of the attention-span of the developer, or is there no correlation that could be reliably drawn? (Note: I understand people do program in other countries, and I have used English as an example here. I also respectfully understand that someone whose first language was _not_ English may find it difficult. This question is aimed at those who _should know better_ )


Can I consider interface methods as abstract methods?

I was thinking about that, and I had some doubts. When I declare an interface, for example:               public interface MyInterface     {        public void method1();        public void method2();     }      Could these interface methods be considered abstract? What I mean is that the concept of an abstract method is: > An abstract method is a method that is declared without an implementation > (without braces, and followed by a semicolon). So, could these methods be considered abstract? They are not "pure" abstract methods as I'm not using the `abstract` word, but conceptually, it looks like they are. What can you tell me about it? Thanks.


Uses for System.gc() in Java

In Java, there is a method called `System.gc()`, which calls the garbage collector (or rather, "suggests" to the JVM to run the GC). Are there valid reasons to call this method? I'm thinking that it would be evident of bad software design.


Avoiding IllegalStateException in MVP when view is not ready yet

In an effort to improve my coding skills I am trying to make use of the MVP pattern in one of my first Android applications. It is going well but I have hit one issue that I am not sure what is the "proper" way to deal with. I have a View class that contains a Google Map object. It also contains a "spinner" that allows the user to select among a number of modes for centering the map.   * case 0 is center on a particular user marker   * case 1 is center on the center of the group of markers When the user selects one of these modes the presenter is notified and depending on the mode, works with the model to figure out what new center of the map should be and then tells the View to recenter the map. The problem is that when the device is rotated the whole "system" is restarted and one of the first things that happens is the android system sets the spinner to the state it was in before it was rotated. This triggers the recenter method which tries to recenter the map before it is ready. My quick fix for this was to check something in the Model class that should only be true if the map is ready, i.e. there are markers that should have been displayed already.               public void centerOnModeSelected(int position) {         centerOnModeIndex = position;         if (mMapMarkers.size() > 0 ) recenterMap();          }      What I am planning on doing is this: In the presenter constructor, I would have a field               private Boolean mapIsReadyForUpdates = false;      and a method               public void setMapIsReadyForUpdates() {          mapIsReadyForUpdates = true;     }      and then I would have the View call that method after it has added some markers to the map, or whenever I can be sure It is ready to accept the methods that are currently generating the exceptions. I guess the other option is to hold that state in the view itself and then block the calls to the map object based on the view's state. My current methodology is to not have the view maintain state, the presenter is maintaining the state. I am assuming others have dealt with situations in MVP were a view my not be in a state were it can accept calls to particular methods. Can someone help me understand the trade-offs with my 3 solutions, or suggest a better solution? My "quick fix" works, but seems like a hack. If there are no markers there is no need to recenter the map, but the fact that markers exist does not mean the map is ready to be updated either. **UPDATE** Since the presenter completely controls the view, it knows when the map is ready to be updated, so all I needed to do was to create a field in the presenter (as mentioned above), and then set it to true, once I was sure I created the map in the view. Then check that field before calling any methods that would try to update the map. I guess this makes perfect sense for the MVP pattern.


How should I bring my C++ back up to date with modern developments?

How should I bring some very rusty C++ up to date, as I'm sure the language and best practices have evolved? I realise this might be close to being off- topic so let my clarify some details. About 10 years ago I think I was quite a good C++ programmer, I'd devoured the Scott Meyers books, I could solve the puzzles in the lint adverts in Dr. Dobbs. I was probably a bit of a language lawyer. I've been programming mostly Java, some python for the last 10 years so my OO skills are still up to scratch. But having joined a company where C++ is common I've realized I have to admit to myself I am both really rusty, and there are language features now which are either new or a lot more common than I remember - things like namespaces etc. I realise reading and writing code (especially pairing) is a good way to get up to speed, but is there any other resource people would recommend in this to give me an accelerated head start. Book? Web-page? Tutorials? To summarize:   * Recommendations for C++ specific refresher resources?   * Not OO/programming generally.   * Things in addition to just reading and writing code.


Are there any reasons not to use distributed version control in a corporate setting?

> **Possible Duplicate:**   >  What does SVN do better than git? In an effort to push coworkers toward a distributed VCS, I'd like to first understand why it is **not** a good change from a practical perspective. Why might a centralized VCS be preferred over a distributed one in a corporate setting?


if you were asked to answer to the question " what is the difference between the English language and a programming language" how you will respond?

Basically in both cases you have:   * a well defined vocabulary   * a syntax to respect   * they both can express a business logic   * they can define semantics I don't think that will be fair to say "A programming language is only useful for a PC" or something like that. I just can't find a real answer, but we can feel the difference, it's strange.


ORM has schema to generate classes, does the reverse exist?

In Entity-Framework, you can create a DB schema, and then generate your ORM classes. Is there any software that does this in reverse? For example you create a few classes that have relationships, and software generates a database schema with the relevant primary and foreign key relationships?


For a Javascript library, what is the best or standard way to support extensibility

Specifically, I want to support "plugins" that modify the behavior of parts of the library. I couldn't find much information on the web about this subject. But here are my ideas for how a library could be extensible.   1. The library exports an object with both public and "protected" functions. A plugin can replace any of those functions, thus modifying the library's behavior. Advantages of this method are that it's simple and that the plugin's functions can have full access to the library's "protected" functions. Disadvantages are that the library may be harder to maintain with a larger set of exposed functions and it could be hard to debug if multiple plugins are involved (how to know which plugin modified which function?).   2. The library provides an "add plugin" function that accepts an object with a specific interface. Internally, the library will use the plugin instead of it's own code if appropriate. With this method, the internals of the library can be rearranged more freely as long as it still supports the same plugin interface. This could also support having different plugin interfaces to modify different parts of the library. A disadvantage of this method is that the plugins may have to re-implement code that is already part of the library since the library's internal functions are not exported.   3. The library provides a "set implementation" function that accepts an object inherited from a specific base object. The library's public API calls functions in the implementation object for any functionality that can be modified and the base implementation object includes the core functionality, with both external (to the API) and internal functions. A plugin creates a new implementation object, which inherits from the base object and replaces any functions it wants to modify. This combines advantages and disadvantages of both the other methods.


What languages should I know if I'm interested in building web applications?

I'm interested in developing for the web and I'm curious what languages should I know besides html, css, javascript, php/python/ruby. I don't know much about c# or java to make a decision whether to learn them or not, are they used much in the field I'm interested in? What other technologies should I look into ?


What are technical writing principles?

As a programmer, technical writing is an important skill to me. I get a lot of fun from it. I also learned from some good technical articles and books. What I need are technical writing principles or rules to refresh my mind. Any relevant article, tutorial, and presentation are welcome, and your own experience will also be great!


How to properly deprecate methods in Java?

Today I lost a method that I was using since my co-worker redefined it to take its superclass instead. So after synchronizing with the repository I had trouble. Would it had been better in this case to use some annotation like `@Deprecated` instead of removing the method so that I would get an error message telling my that the method was deprecated? Can a version control system or an IDE work around situations like this by deprecating methods instead of deleting them?


How do I know if I am using Scrum methodologies?

When I first started at my current job, my purpose was to rewrite a massive excel-VBA workbook-application to C# Winforms because it was thought that the new C# app will fix all existing problems and have all the new features for a perfect world. If it were a direct port, in theory it would be _easy_ as i just need to go through _all_ the formulas, conditional formatting, validations, VBA etc. to understand it. However, that was not the case. Many of the new features are tightly dependant on business logic which I am unfamiliar with. As a solo programmer, the first year was spent solely on deciphering the excel workbook and writing the C# app. In theory, I had the business people to "help" me specify requirements, how GUI looks and work, and testing of the app etc; but in practice it is like a contant tsunami of feature creep. At the beginning of the second year I managed to convince the management that this is not going anywhere. I made them start from scratch with the excel-VBA. I have this "issue log" saved on the network, each time they found something they didn't like about the excel-VBA app, they will write it in there. I check the log daily and consolidate issues (in my mind) mainly into 2 groups: (1) requires massive change. (2) can be fixed in current version. For massive change issues, I make a copy of the latest excel-VBA and give it a new version number, then work on it whenever I can. For current version fixes, I make the changes in a few days to a week, and then immediately release it. I also ensure I update the same change in any in-progress massive change future versions. This has gone on for about 4 months and I feel it works great. I made many releases and solved many real issues, also understood the business logic more and more. However, my boss (non-IT trained) thinks what I am doing are just adhoc changes and that i am not looking at the "bigger picture". I am struggling to convince my boss that this works. So I hope to formalise my approach and maybe borrow a buzzword to confuse him. Incidentally, I read about Agile and SCRUM, about backlog and sprints. But it's all very vague to me still. **QUESTION (finally):** I want to tell him that this is SCRUM! But I want to hold my breath first and ask whether my current approach is considered SCRUM or SCRUM-like? How can I make it more SCRUM-like? Note that I have only myself, there's no project leader or teams.


Review before or after code commit, which is better?

Traditionally we performed code review before commit, I had an argument with my colleague today, who preferred code review after commit. First, here's some background,   1. We have some experienced developers and we also have new hires with almost zero programming experience.   2. We'd like to perform fast and short iterations to release our product.   3. All team members are located at the same site. The advantages of code review before commit I've learned:   1. Mentor new hires   2. Try to prevent errors, failures, bad designs early in the development cycle   3. Learn from others   4. Knowledge backup if someone quits But I've also had some bad experiences:   1. Low efficiency, some changes may be reviewed over days   2. Hard to balance speed and quality, especially for newbies   3. One team member felt distrust As to post-commit review, I know little about this, but the thing I'm most worried about is the risk of losing control due to lack of review. Any opinions? **UPDATE:**   1. We're using Perforce for VCS   2. We code and commit in the same branches (trunk or bug fixing branches)   3. To improve efficiency, we've tried to split code into small changes. We've also tried some live dialog review, but not everyone followed the rule. This is another problem though.


How to find a programming mentor?

I decided to learn programming. I've been reading SO for few days, and I think I will start with C++, as I read some articles. I am aware of loops, arrays, program logic and objects a little and I need someone to look me over and help me with small questions I get when doing my first projects. So here is the question - where do I find such guy? I don't got any friends who program and all. EDIT: 2 years later, I am still looking for mentor. I did not actively code just started 3 months again. I work on Objective-C and iOS programming and game programming with Cocos2d. If you want to become my mentor, drop me a or comment.


Finding a Programming "Mentor"

> **Possible Duplicate:**   >  How to find programming mentor? I've been programming for a while. I've read several books, have tried out several languages (Perl, Ruby, Python, C++, .NET, HTML, CSS, JavaScript, SQL), and have taken tons of advice and I feel like I have greatly progressed, fast. But I feel like I would've learned more if I had a mentor. Well... not a tmentor. More of someone that can guide me, and somebody that I can ask if I had a problem. Yes, StackOverflow is great, Programmers-SE is amazing, and there are huge community's for languages, but it isn't the same as having a "mentor". So, where can I find one? Like I said, I'm not looking for someone who will teach me everything, or somebody who I will have to meet once a week. Just emails here-and-there. Nothing major. Of course I would _like_ it to be free. But where and who? Is there a website or organization that can help me? Somebody you know? Thanks so much!


Do all programmers going through a steep learning curve?

I don't have many peers who work as a programmer or at least who are social enough to share some parts of their precious knowledge, so I have little to none to compare with. I tend to learn new things by myself, but each time I started to learn A, it got hooked up with B, which ends up hooked up with X, etc. In the end, I learn almost nothing but that programming for a newbie is painful. The first part of the learning curve seems insanely steep for a beginner like me which at some point seems to be irrelevant. Am I a bad programmer to have experienced this? Or is there a fellow programmer out there who has experienced this and survived, and care enough to share how? Edit : Since it marked as duplicate, I checked the question link given. The only thing that is similar between my question and the given one, is we both is quite alone in our programming field. But what I asked is this, is all programmer going through this steep learning curve? And if they do (which means I am not necessarily a bad programmer), how do they survived through it?


Defining a standard

How would you go about defining a standard? I am defining a protocol for a sort of thing that does not exist yet and I would like to create an RFC for it, and use a well-known port number provided by IANA. How do I start?


How to explain programming to a non-programmer?

> **Possible Duplicate:**   >  How do you share your craft with non programmers? I tend to think that I might get such a question in the future... How should I answer to it in layman terms?


What to teach a 12-year-old VB programmer about programming in general

I am mentoring a 12-year old in programming. He has started to do some VB (.net) (2008) and is making simple WinForms programs, but does not get some of the basic concepts (loops, functions, datatypes) Coming form a C/C++ background, I don't know where to start I don't think he's is up to c/c++ or java quite yet


How do you portray to non programmers what programming involves?

I get casually asked a lot to take a couple days to teach someone how to program. Most people really think they can learn what I know in a few days. When I tell them I have been doing this for many years and I can't teach them to be a programmer in a few days, they look at me like I am being a jerk and just don't want to help them. I think this is because when I say I am a programmer, or I programmed _this_. I truly think most people do not realize that I mean I wrote the code that makes it up. I think that they think I mean I configured it, like when you say, "I programmed my VCR." Does anyone else think this? Whats your experience?


I have a hard time explaining what I learn

> **Possible Duplicates:**   >  How do you share your craft with non programmers?   >  How to explain programming to a non-programmer?   >  How do I become more articulate? I love programming and I like to learn everything I read about the subject. However, I'm having a hard time explaining what I've learned to someone who does not know anything about programming or even to a fellow programmer. There is a quote by Albert Einstein that goes something like this:                If you can't explain it to a six year old, you don't understand it yourself.       or                If you can't explain it simply, you don't understand it well enough.      Does anyone else find themselves in the situation I'm in? This can also affect my job interviews; when someone asks me to explain some concepts that I know but can't put it well enough in words, they might think I'm not well prepared when in fact I am but I'm crippled by my inability to explain myself. How can I overcome this and be more articulate?


How do you share your craft with non programmers?

Sometimes I feel like a musician who can't play live shows. Programming is a pretty cool skill, and a very broad world, but a lot of it happens "off camera"- in your head, in your office, away from spectators. You can of course talk about programming with other programmers, and there is peer programming, and you do get to create something that you can show to people, but when it comes to explaining to non programmers what is it that you do, or how was your day at work, it's sort of tricky. How do you get the non programmers in your life to understand what is it that you do? NOTE: this is not a repeat of Getting non-programmers to understand the development process, because that question was about managing client expectations.


Can Dependency Injection used as an alternative to Reflection for creating instances

There is a piece of .net C# code which use Reflection to create an instance using `Activator.CreateInstance()`. This is an old piece of code and runs on the top of Enterprise Library. Is it a better idea to replace this with Dependency Injection to create objects? Is there any Pro's and Con's for either approach?


LUA vs Shell scripting vs C for cgi-scripting on embedded devices

I am going to try CGI scripting for implementing a web based Graphical User Interface on an embedded device. What advantages does LUA scripting have over shell scripting or C for implementing dynamic HTML files? Which one do you think is easy-to-use from developer's perspective. My GUI will comprise of some form based HTML pages. Some times, I would like a C program to run corresponding to an action performed on the GUI and then display result of the program to the user on GUI. Will shell scripting suffice in such a scenario or will I 'have to' use LUA? I have some experience with shell scripting actually.


VPN or TLSv1 for securing a programs protocol from field device to mainframe

I am working on a product that requires devices to exists anywhere in the world hooked up to the internet though cell modems or on WLAN lines which communicates to a server(s) that exists elsewhere in the world. _When deigning the networking portion of the program i cant figure what the best option is for securing the communication between the server and end device._ From my searches iv'e come up with two options. **Option 1:** _Using a host to host vpn connection between the two devices._ **Pros:** VPN software seems to be well tested and does not require extra programming for the network protocol. The IT department is more comfortable with it because of using software that is already tested and they comfortable with vpn. **Cons:** Since my end devices are linux on OMAP platforms cross compiling the vpn software if not already done could be tricky. Dealing with firewalls and routers behind the end devices network. Setup of the connection can be tricky. **Option 2:** _Implementing the TLSv1 protocol in my program to deal with the encryption._ **Pros:** Does not require extra software to be running on the device. Only relies on the encryption libraries as a dependency. Don't have to worry about dealing with nats and firewalls because the protocol will only require one tcp port to be open. **Cons:** Extra coding to the network software. IT is skeptical because our program is responsible for securing the protocol. **FYI:** For implementing the TLSv1 i would use http://www.gnu.org/software/gnutls/


What should be done on git while migrating new distribution and packet manager?

In the project I am working, we are using Freebsd and we are creating our software packages for it. Now we are planning to change distribution to Centos and rpm for packet manager. Since our codes are not platform independent, we have to make many change on it. Also we will continue to use freebsd until migration is completed. What is the best git usage way for this type of migration. Should we use a new branch or a new repository?


Softpedia published some of my open source projects — how to react?

_(FYI: I've just moved this question over from Stackoverflow on recommendation.)_ I just received a few emails, informing me that softpedia.com has added some of my "products" to their "database of scripts, code snippets and web applications". My products are in this case some smaller open source projects, which I have hosted and published on github. Now I'm wondering how to react to this. This site is indirectly making money of my free work through ads on three pages before the actual download. They also seem to "invent" version numbers and I can't find out if they're hosting the latest or all versions of my projects. — I can see how this could lead to problems in the future, since I don't control what's "the latest" everywhere. On the other hand I don't mind some extra publicity. I want as many people as possible to know about the projects, use them, fork them and hopefully improve them. The projects in questions are really fairly small, but this might not be the case in the future for me and/or other people reading this question. I'm sure that this must have happened to others around here. What's your opinion? Should I try to get the downloads removed? * * * **Update 1** I've requested the removal and mentioned that I don't feel that Softpedia can provide the right environment for this kind of project. Their team got back to me instantly with a friendly email saying, that they'll remove the links for now: > If you are worried that your projects won't be updated, then I must tell you > that I have them bookmarked in my RSS reader, so any version changes will be > forwarded to me when needed. So I promise I'll keep your script up to date > as soon as I see an update in the repository. I have to say, that I appreciate this kind of reaction quite a lot and so I sent them another email, describing in more detail what I'm worried about and what bothers me. I also stated, that I'm aware that my license clearly permits them to host the projects in any case, but that I'd be even happy if they would host the projects as long as they could convince me of a few details and maybe make some small changes to the way the projects are represented. — Let's see where this goes. * * * **Update 2** After discussing with their contact and requesting some changes regarding display of version (they had given the possibility to do so) and authorship they put the projects back up on their site. All in all a positive and definitely interesting experience.


Advice sought: highly technical app idea - do I employ someone or do it myself?

I'm a TV producer in London but also an enthusiastic amateur coder and web designer. I started with VB6 and then moved onto C/PHP/Obj-C. I've got a couple apps in the app store, I mess around a lot with Arduino, create php CMS from scratch - but I've certainly never worked professionally as a coder. I've got an iPad app idea which I'd like to spend time and money, but it involves animation and modelling, creating a timeline UI, working with multiple camera views. Put simply, it's a complex OpenGL app, well beyond my skills. _To be clear, this isn't a zombie slasher or fantasy adventure clone - it's an app I know that thousands of well-paid TV industry pros and media students would want to spend money on._ I'd like to know from those with experience of taking a complex app from idea to delivery, whether themselves or through a dev agency, if you genuinely believe an app is worth building should you spend 12 months learning the skills and hacking early versions together - or should you get serious and employ people with money raised from various sources. Perhaps a Kickstarter? With the latter in mind, what is a reasonable amount of money you would pay for a pair of programmers to achieve this, in say six months? Standard pay for a competent opengl coder? It may well be a case of using out-of-uni programmers and splitting the company with them, plus modest expenses. I think I'm in a fortunate position that I can at least contribute to the project, through graphics, audio, marketing - just not the real heavy stuff. Any advice genuinely appreciated, Mike.


Django application strategy

I have been working a while on a Django project which has been growing a bit lately. I have been think a bit about what strategy to use to make it easier to handle. One thing I would like to get some input on would be if I should split my application into several smaller applications. That would make my view and model files smaller and separate some of the concerns. One thing that bothers me with this is that in my applications I would have several helper methods that will be used across applications. Also some models will also have to be shared/used across applications. Would this make sense? This doesn't go well with the separation of concerns I was hoping to achieve by splitting my app in several smaller apps. What would be a good approach for sharing helper methods, models etc. across applications?


What degree of low-level programming can be achieved with Languages like Go?

Go and D provide garbage collection, and yet they claim to be system programming languages. What degree of low-level programming can be achieved with languages having garbage collection? For low-level programming, I mean close to the hardware or being able to:   1. Runs directly in limited memory, with no latency, and performs well. An example would be operating system kernels.    2. It runs on a software base, but still has to perform well. An example would be system utilities.


Why this code create object as interface?

In am reading Spring in Action (3rd edition) and here a snippet from it:               ApplicationContext ctx=new ClassPathXmlApplicationContext("springidol.xml");                 Performer performer=(Performer)ctx.getBean("poeticDuke");                 performer.perform();      It doesn't has any problem,however, when the author introduce the init-method and destroy-method:               <bean id="poeticDuke"             class="com.springinaction.springidol.PoeticJuggler"             init-method="turnOnLights"             destroy-method="turnOffLights">      Somehow the output only got the init-method but not the destroy-method. Then I realized that the context call destroy-method upon its close and I tried to code as following:                   ApplicationContext ctx=new ClassPathXmlApplicationContext("springidol.xml");                     Performer performer=(Performer)ctx.getBean("poeticDuke");                     performer.perform();     ctx.close();      It doesn't compile because the interface ApplicationContext doesn't have the method close. It only work as following:               ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext("springidol.xml");                     Performer performer=(Performer)ctx.getBean("poeticDuke");                     performer.perform();     ctx.close();      Why did the author wrote it that way?


Accurate calculation of a raster image's boundary length

I have a rasterized image that contains two colors: white and black. The black portion is entirely connected and looks like a big blob. Is there a good way to estimate the length of the boundary between the regions? One method I have considered is to simply count how many "edges" of the rasterized grid have a different color on each side. However, for e.g. a purely diagonal line, this will overestimate the distance of the boundary by a factor of sqrt(2). Is there a better method for estimating the boundary length which does not have this problem?


Should I use JavaFx properties?

I'm usually very careful to keep my Model, View, and Controller code separate. The thing is JavaFx properties are so convenient to bind them all together. The issue is that it makes my entire code design dependent on JavaFx, which I feel I should not being doing. I should be able to change the view without changing too much of the model and controller. So should I ignore the convenience of JavaFx properties, or should I embrace them and the fact that it reduces my codes flexibility.


Is creating database index part of design, implementation or optimisation process?

There are a few questions around this subject:   * Is creating all indexes at the start (design) over engineering?   * In reality, I've added indexes after performance issues were found and we 'explain plan' and add indexes as needed (i.e. not for all relationships). Should I just skip creating indexes before it's needed because performance issues will show up anyway and probably the indexes that's already been created aren't being used?   * Should indexes be treated as part of requirement/specification? Sometimes I see performance requirements, which is usually vague or random. If they're part of specification, then should managing indexes be part of implementation? I want to make it a bit clearer and more background. In development, usually the different phases involve different kinds of people (e.g. architects, seniors and juniors). It'd be unusual for juniors to be responsible for the design, for example. So, when some tasks overlap, it becomes unclear who's responsible if, for example, a query takes 2 second. Defining development phases and responsibilities are also important for non- programmers, e.g. project managers or product owners, because they are needed for planning and costing. A project manager might want to higher an architect to do all database related task only at the start and for a short time. If after product launch, it's found that performance is poor, the PM would like to know who's responsible. I hope you get the idea.


How do you let a user choose the app database location?

Writing software for a client, and one of their requirements was that the user be able to specify where the application database is stored, be it on the local network or in an online repository. I can let them choose where to put it, but how do I store that information in the application? I guess I don't understand how to persist changes in an application that is already deployed. This is my first piece of software, so I've never been through the deployment process. Written in C# for Windows.


What metrics should be used to measure memory consumption of a program for performance test?

I am asked to provide performance statistics for a program, one of them being memory consumption. I noticed that in perfmon or in .NET API there is apparently many variable related to memory usage, such as private bit, working set, page file, etc. What are the difference, and which one should we use for measuring performance? If the vendor claims that the memory consumption of the program is improved in version X, what value can be used to validate this?


Drawbacks to entirely Ajax driven CMS

I'll try to keep this question as specific as possible.. I'm about to start building an API for an upcoming project. I'm currently thinking PHP/Symfony2. It will be a farily simple HTTP-based api for CRUD on the site's models (and relationships between them). There will also need to be a CMS for users. Traditionally when building a CMS (if it's bespoke) I'd just use some standard MVC based approach, but for this particular project I'm thinking I could build it using Ajax calls to the API that will already exist. My question is essentially to decide which way to go, but to keep it specific I'd like to know what drawbacks there might be. In favour of this, it should reduce duplication of controller logic, why have `/api/model/save/` and `/cms/model/save` doing very similar things? Currently the only two drawbacks I can think of are that:   * It may be hard to support a wide range of browsers. For this particular scenario, this shouldn't be a problem - but who knows what might happen in the future?   * Some parts of the site would require traditional PHP logic or an extension to the API (for any parts not part of the core API itself), for example to handle admin authentication. Is there anything I've missed, some overwhelming reason not to take this approach?


How to find a scaling expert?

The web application is in ASP.NET and Sql Server and is growing much faster than anticipated. Where can I find an expert who has previously had experience of going from a small website to solution used daily by thousands? Someone who can review our system and give us advice on performance improvements and updating our coding practices.


Linux kernel development

I am trying to understand the linux kernel and there is one thing that is puzzling me for quite a while. As linux is used across variety of platforms (like smartphones,desktop,supercomputers etc) and also on various architectures, so does the same kernel code is used by all or a different one and also since it includes some assembly codes so it must be architecture specific. so do the developers in linux community apply patches to a single kernel or there are multiple versions of kernel each for different architecture and platforms?


What is the most elegant way to handle a loop between two systems integrated remotely by webhook events?

So I'm developing this small engine that does a remote integration between two systems in order to sync data, both systems have webhooks for create & update events, and both have APIs (one is REST one is XML), so it is an event-based integration rather than a typical batch one. My problem is that if System A creates an entry and fires a webhook that the engine catches, if the engine doesn't find it, then it creates a comparable entry in System B which triggers a create webhook, which then the engine catches as a new request... and you see my problem. Same scenario could happen for an update webhook (actually this one is more likely to happen). I'm guessing I'm not the first person on the earth to encounter this problem, so I'm wondering what would be an elegant way of handling this given that I cannot modify the APIs, nor inject custom metadata in the messages that could help me catch the loop. FYI, the integration is between two issue tracking systems.


What exactly is the build number in MAJOR.MINOR.BUILDNUMBER.REVISION

What I think about Build Numbers is that whenever a new nightly build is created, a new BUILDNUMBER is generated and assigned to that build. So for my 7.0 version application the nightly builds will be 7.0.1, 7.0.2 and so on. Is it so? Then what is the use of a REVISION after the build number? Or is the REVISION part being incremented after each nightly build? I am a little confused here... do we refer to each nightly build as a _BUILD_? The format is mentioned here: AssemblyVersion - MSDN


Should I go to a job interview even though I know I won't get it?

Here is the opportunity I've been given. I'm currently a freelance web developer and completely self-taught. I have but an NVQ in Business Administration. However, I am passionate and committed to programming and building websites and applications, of which I've been doing for a good 3-4 years. Instead of being offered an interview, I've been offered a day trial for what could turn into a 6 month contract. The pay is good, but I'm more thirsty for the commercial experience. Thing is, I know there are gaps in my knowledge. I lack fundamental programming concepts, I never studied computer science and I use google to find optimal solutions to problems I come across. I feel more experienced programmers in the team will see this almost instantly. But will they sympathize having hopefully been at my level once? I'm thirsty to grow and I've spent a good 15 hours a day working in web development and honing my skills - but they are very particular. I know html, css, javascript, jquery, ajax, php, git...I'm a good developer but I don't think I'm good enough for someone to pay me £100/day. The way the trial works is during the first half of the day I am introduced to the team and the different departments. During the second half, in the afternoon, I am given a 'live task', a duty I'd perform if I'd be working there. I already know in advance it has something to do with converting a word document into html using php..it seems like they are trying to bend the language to do something it isn't meant to do, and the first place I'd start is Google to research php libraries. Advice? Should I go even though I know I probably won't make it past the first day and probably embarrass myself, just for the experience? Will this help me grow as a programmer? I don't want to waste people's time. I will still give it my all. Appreciate input from people who have been in similar situations.


how to deal with clients who don't know any programming skills

Have you ever handled a Client who doesn't know anything about programming or no technical skills who doesn't even know how to turn on a Computer? What he only have is the idea, which is a great one, but doesn't know how to implement it so he hired some programmers to implement his idea. Some over excited programmers likes the idea and eager to implement it without thinking of any possibilities that a problem might occur. Now both parties (Client and developer) have agreed on something after plotting a timeframe of the project and benifits. And then there comes the part where you are almost finish the project, and your client comes across with another idea and wants to implement it. And as a developer you know the possibilities of implementing that, and you found out that it would destroy 50% of what you've done and needs to extend the timeframe for atleast 50% of the one you agreed on. As for the clients side, it is just a little feature that needs to be added, and because I'm nearly done with everything, he thought it is just a brick that needs to be placed on the wall, unfortunately that brick is in the middle of the wall.


100K curl requests

I am using curl_multi_exec to process over 100K requests. I do 100 requests at a time because curl_multi_exec can only handle 100 requests at a time to eventually get to 100K requests. We have added multiple servers to this system to spread the load [we are using load balancing]. What is the best way to have curl handle 100K requests and make use of these additional servers? What is the downside (other than time) of handling that many requests on one server? How can I use the additional servers to help handle those requests? I was thinking about having each server handle a batch of requests (like one server handles 500 requests, another 500, another 500, etc.. To elaborate- basically, we are using curl to send out over 100K requests to third party servers. The problem with only using 1 server is that there is a memory limit in the number of requests 1 server can handle. So we decided to add additional servers, but we are not sure how to design this system to use curl to handle that many requests.. The third party server is an API like Facebook; they are aware that we will be making that many requests to their servers. For load balancing, we use Rackspace cloud server, basically the load balancer directs incoming requests to separate servers.


> **Possible Duplicate:**   >  Whats the difference between a Software Architect, a Software Engineer, and > a Software Developer (Programmer)? I have had many discussions about the role of a software architect and did not reach a conclusion. So I decided to change the question. What the difference of Skills between a Dev Senior and a Software Architect?


Whats the difference between a Software Architect, a Software Engineer, and a Software Developer (Programmer)?

I'm reading through the CNN article about the highest paying jobs in America. A software architect is listed as #1. A software engineer listed as #9. And a software developer (programmer) is listed at #35. I think it's valid to replace computer scientist with programmer, right? Prior to this I always saw "Software Engineers" as being the title for experienced programmers and team leads. But where then does a "Software Architect" fit in and what exactly do they do? I read the CNN descriptions but they don't really satisfy me so I'm assuming I can get more thorough and experienced descriptions from the awesome user base here. Thanks in advance for any and all responses received.


"Do it right, against customer's wishes" - how is it called?

We know the optimal situation of negotiating corrections of specifications with the customer, getting the specs to do what the client wanted, not what they said or thought they wanted. That's negotiating, explaining. Sometimes, we're unable to convince the client. We're forced to produce broken as designed. This, called "demonology" by merit of mages summoning demons and demons fulfilling their wishes very literally, causing the mage's demise as result, is another approach that will leave the customer very dissatisfied once they realize their error, and of course try to pin the blame on the developer. Now I just faced a very different approach: the customer created simple specs that fail to account for some critical caveat, and is completely unwilling to fix them, admit the obvious errors and accept suggested corrections. The product made to these specs will be critically broken, and possibly might cost human lives. Still, it's too late to drop the contract entirely. The contract has punitive clauses for that, ones we can't really accept. The boss' decision? We do the work right and lie to the customer that we did it according to the specs. The algorithms in question are hidden deep enough under the surface, the product will do the work just fine, won't fail in the caveat situation, and unless someone digs too deep, they will never discover we didn't break it as requested. Is there some common name for this tactics of execution of specs?


Display large amount of data to client through pagination

I have a web application in which i need to show a big number of data or records for clients. Now i 'll use pagination but i was wondering should I:   1. Load all the data once then pagination, sorting and sarching 'll be easy..But it 'll takes big time(using local DB it takes up to 9 sec.)   2. Or each time i show new page(from the pagination) i make a new request to server and then new request to DB to get the next records..But then what if the client click on `Prev` button, i 'll make a new request to get data that I had previously..Should i cach data that are loaded before and how if that's good technique?  So load all data once or make a new request every time i need data that maybe have been loaded before. I'm using ASP.NET MVC SPA with durandaljs and knockoutjs


Who is responsible for the development of Java?

When I google about Java, the companies most mentioned are Sun, Oracle and IBM. I know that Oracle bought Sun, and the Java official website is Oracle domain, so I can assume that Oracle is the official Java developer. But after a little research, IBM also provides many tutorials and documents about Java. Why is this? Is IBM also involved in some development of Java?


audio and video data in RTP

Suppose a user wants to transmit both audio and video to another user, whose formats are AMR for audio and H.264 for video. Does the user have to transmit audio and video packets always separately? Meaning that it is not possible to mix audio and video within the same RTP packed, is that correct? If this is true I guess the RTP protocol will need to know the SSRC of both audio and video to be able to check the sync of the two streams.


Compound container for storing output from a parser

Consider a hierarchical structure like this               directory         [              [item_0;item_1;...;item_n]              [item_0;item_1;inner_directory[...];item_m]              other_directory                  [...]         ]      A directory contains   * An array of strings (delimited by ';' in input data)   * A map from name to sub-directories (the name of the directory is followed by '[')   * An array of unnamed sub-directories The directory can be described by this class:               class Directory         {         public:             //Appropriate operations         private:             std::vector<std::string> items;             std::map<std::string, Directory> named_dirs;             std::vector<Directory> unnamed_dirs;         };      However:   * The Directory class requires three sets of operations, resulting in a large class definition   * A copy operation will be recursive Can the data be stored in a better way avoiding at least the first point?


On mobile is there a reason why processes are often short lived and must persist their state explicitly?

Most mobile platforms (such as Android, iOS, Windows phone 7 and I believe the new WinRT) can kill inactive application processes under memory pressure. To prevent this from affecting the user experience applications are expected to save and restore their state as their process is killed and restarted. Having application processes killed in this way makes the developers job harder. On various occasions I've seen a mobile app that would:   * Return to the welcome screen each time I switch back to it.   * Crash when I switch back to it (possibly accessing some state that no longer exists after the process was killed)   * Misbehave when I switch back to it (sometimes requiring a restart or tasks killer to fix)   * Otherwise misbehave in some hard to reproduce way (e.g. android service killed and restarted at the _wrong_ time) I don't really understand why these mobile operating systems are designed to kill tasks in this way especially since it makes application development more difficult and error prone. Desktop operating systems don't kill processes like that. They swap out unused pages of memory to mass storage. Is there a reason why the same approach isn't used on mobile? Mobile hardware is only a few years behind PC hardware in term of performance. I'm sure there are very good reasons why mobile operating systems are designed this way. If you can point me to a paper or blog post that explain these reasons or can give me some insight I'd very much appreciate it.


scalablity of Scala over Java

I read an article that says Scala handles concurrency better than Java. http://www.theserverside.com/feature/Solving-the-Scalability-Paradox-with- Scala-Clojure-and-Groovy > ...the scalability limitation is confined specifically to the Java > programming language itself, but it is not a limitation of the Java platform > as a whole... > > The scalability issues with Java aren't a new revelation. In fact, plenty of > work has been done to address these very issues, with two of the most > successful projects being the programming languages named Scala and > Clojure... > > ...Scala is finding ways around the problematic thread and locking paradigm > of the Java language... How is this possible? Doesn't Scala use Java's core libraries which brings all the threading and locking issues from Java to Scala?


questions on a particular algorithm

Upon searching for a fast primr algorithm, I stumbled upon this:                 public static boolean isP(long n) {          if (n==2 || n==3) return true;          if ((n&0x1)==0 || n%3==0 || n<2) return false;          long root=(long)Math.sqrt(n)+1L;         // we check just numbers of the form 6*k+1 and 6*k-1          for (long k=6;k<=root;k+=6) {              if (n%(k-1)==0) return false;              if (n%(k+1)==0) return false;          }          return true;      }         My questions are:   1. Why is long being used everywhere instead of int? Because with a long type the argument could be much larger than Integer.MAX thus making the method more flexible?   2. In the second 'if', is n&0x1 the same as n%2? If so why didn't the author just use n%2? To me it's more readable.   3. The line that sets the 'root' variable, why add the 1L?   4. What is the run-time complexity? Is it O(sqrt(n/6)) or O(sqrt(n)/6)? Or would we just say O(n)?


How to fit testing in Scrum sprints and how to write user stories in Scrum

I am the development team lead of a new project at my company. This is the first project where the company will use Scrum. We have a waterfall/iterative SDLC. The BAs write requirements docs, hands over to dev and test, dev start developing and will release to testing in iterations. Testers take long time to test a release by which devs continue development but also bug fixes for the current release. I have a few questions   1. In a sprint with say 5 stories when do you release for testing ? Is it as soon as a story is completed by dev or after all stories are completed but before end of sprint giving test the required time to test.    2. If the BA writes user stories what should be the detail. Traditionally it takes long time to write a spec with all UI layout, behaviour, text etc to be finalised. I guess my question is how to write stories that are implementable and testable.   3. Our test team is non-technical. How important it is to have automated UI testing for Scrum. The UI is based on WPF. I have solid development experience using agile methods (TDD, code reviews, refactoring etc.) but new to scrum. edit: By iterations I mean that if there are 100 requirements we may release to testing when we have finished 30, 35, 35 requirements rather than wait till all 100 requirements have been completed.


How do you integrate Testing into a Scrum process?

This is really perplexing me. We have a 'definition of done' and it includes dev 'done', unit tests 'done', dev test 'done'. However we also have a user acceptance test that needs to be 'done' but the business wants to know when users stories are complete so that they can see stuff (the uat really isnt a priority until release). But because this is outside of the initial done (where we pass our user stories) how can we say its done? And where does this fit into estimating? Where can I find information on integrating testing with a scrum process? I think I need to read up this...


Functional Programming: right ideas about concurrency and state?

FP proponents have claimed that concurrency is easy because their paradigm avoids mutable state. I don't get it. Imagine we're creating a multiplayer dungeon crawl (a roguelike) using FP where we emphasize pure functions and immutable data structures. We generate a dungeon composed of rooms, corridors, heroes, monsters and loot. Our world is effectively an object graph of structures and their relationships. As things change our representation of the world is amended to reflect those changes. Our hero kills a rat, picks up a shortsword, etc. To me the world (current reality) carries this idea of state and I'm missing how FP overcomes this. As our hero takes action, functions amend the state of the world. It appears to be every decision (AI or human) needs to be based on the state of the world as it is in the present. Where would we allow for concurrency? We can't have multiple processes concurrently ammending the state of the world lest one process base its outcomes on some expired state. It feels to me that all control should occur within a single control loop so that we're always processing the present state represented by our current object graph of the world. Clearly there are situations perfectly suited for concurrency (i.e. When processing isolated tasks whose states are independent of one another). I'm failing to see how concurrency is useful in my example and that may be the issue. I may be misrepresenting the claim somehow. Can someone better represent this claim?


Breaking up a large PHP object used to abstract the database. Best practices?

Two years ago it was thought a single object with functions such as `$database->get_user_from_id($ID)` would be a good idea. The functions return objects (not arrays), and the front-end code never worries about the database. This was great, until we started growing the database. There's now 30+ tables, and around 150 functions in the database object. It's getting impractical and unmanageable and I'm going to be breaking it up. What is a good solution to this problem? The project is large, so there's a limit to the extent I can change things. My current plan is to extend the current object for each table, then have the database object contain these. So, the above example would turn into (assume "user" is a table) `$database->user->get_user_from_id($ID)`. Instead of one large file, we would have a file for every table.


How to search for information related to Go programming language?

If there's something that would kill Go language, then it's name. I find it very hard to find anything in web related just by using "Go" in the query. The word is on of the most frequent in English. So I see everything in the result except Go-related stuff. Even Google, who sponsors the language and famous for tracking anything I search, can not track I'm a programmer so interested in the programming language and not English grammar. How to search for information related to the programming language itself, excluding the results related to English grammar? Imagine for example a blog post where someone mentions his observation about Go. He probably won't use the easy-to-search sentence like "go programming language", maybe something "there's one thing I like about Go".


Why can't we declare 'extern C' for C++ macro's?

I am new to C/C++. Wanted to know why we cannot declare 'extern C' for C++ macro's similar to methods/functions...which will allow macro's defined in C++ file to be accessed in .c files. Thanks in Advance


SMS verification in web application

This is my first project related to SMS verification. How to implement SMS verification in online ordering web application? For example:- when we try to reset the password in amazon's website, it sends an sms verification code and after entering the code it proceeds with changing the password. I want to implement the same function in my application, where users will place order, but before the final step it will send an sms verification code to the users mobile and verify the same. The main requirement is SMS Gateway(Transactional Quality). But as I'm completely new in this, so any idea how to proceed, or how can I implement it.


Is "Explain the RAII idiom" a good C++ screening question?

A company that I work with has asked me to do candidate phone screenings to make sure they aren't completely embarrassed when sending over someone to a potential client. It turns out that a fair number of people were being placed for a C++ developer role. I don't spend much time in C++, but I have done a few trivial and non-trivial projects in the language. I figured that "Explain the RAII idiom" would be a nice softball question that most serious C++ developers could answer while half asleep, and would allow me to move on to more interesting questions about experience. But it turns out people who have 10+ years C++ experience don't recognize the term, even if I expand the acronym to "Resource Acquisition is Initialization." One candidate went so far as to say he felt it wasn't always practical to apply the technique in Windows development, which I thought was an odd sentiment, but I could see a couple of examples that arguably support that line of thought. (But really only _arguably_ ). Even a couple of C++ developers I know well enough to judge their competence said they didn't recognize the term, but upon reading a summary of the technique, said "Oh, yeah, I didn't know that had a name. I just thought of those things as something you _just have to do_." I remember the term from the second edition of Stroustrup's book, even though the full impact didn't sink in at the time. So, is "Can you explain the RAII idiom to me?" a fair screening question? Is it reasonable to expect all competent C++ developers to understand it? Is the term more esoteric than I would think? Assuming a candidate doesn't know the term, are there follow up questions that could help me tease out whether they have at least internalized the practices that make RAII work? Are there better alternative "weeder" questions that give the candidate some latitude in answering, and help the candidate demonstrate their understanding of C++ development? **Editing to add** : To clarify, I'm not the sort of interviewer that disqualifies people because they don't know buzzwords and acronyms. However, I do think it's reasonable to expect that an experienced C++ programmer has internalized good practices for resource management. I also think that it's important to verify that a candidate understands some "basics" about the technology they claim expertise in before moving on to more interesting questions about design, problem solving, etc. I think what I'm looking for is a good way to ask an open-ended question, suitable for use in a short telephone screening, that I can use to judge a candidate's basic understanding of good resource management practices in C++, before I ask "hard" questions.


Why do people pick the MIT license over BSD, if BSD's "non-endorsement clause" is a good idea?

According to this question and it's replies What is the purpose of the "non-endorsement clause" in the New BSD license? it seems smarter to pick the BSD license over the MIT, to prevent people using your name in an unwanted way. If that is the case, why do people still pick the MIT license over BSD license?


Best Architecture for ASP.NET WebForms Application

I have written an ASP.NET WebForms portal for a client. The project has kind of evolved rather than being properly planned and structured from the beginning. Consequently, all the code is mashed together within the same project and without any layers. The client is now happy with the functionality, so I would like to refactor the code such that I will be confident about releasing the project. As there seems to be many differing ways to design the architecture, I would like some opinions about the best approach to take. **FUNCTIONALITY** The portal allows administrators to configure HTML templates. Other associated "partners" will be able to display these templates by adding IFrame code to their site. Within these templates, customers can register and purchase products. An API has been implemented using WCF allowing external companies to interface with the system also. An Admin section allows Administrators to configure various functionality and view reports for each partner. The system sends out invoices and email notifications to customers. **CURRENT ARCHITECTURE** It is currently using EF4 to read/write to the database. The EF objects are used directly within the aspx files. This has facilitated rapid development while I have been writing the site but it is probably unacceptable to keep it like that as it is tightly coupling the db with the UI. Specific business logic has been added to partial classes of the EF objects. **QUESTIONS** The goal of refactoring will be to make the site scalable, easily maintainable and secure.   1. What kind of architecture would be best for this? Please describe what should be in each layer, whether I should use DTO's / POCO / Active Record pattern etc.   2. Is there a robust way to auto-generate DTO's / BOs so that any future enhancements will be simple to implement despite the extra layers?   3. Would it be beneficial to convert the project from WebForms to MVC?


centralized hosted application framework or "private copies" for each program?

We have a centralised business application framework, and it contains all our business logic and provides access to all our back-end systems. It is accessed by a number of different programs and clients through remoting. When we need to do a change in a certain part of the program, we currently have to retest all our different programs and clients. Even assuming we extend our automated testing, we feel that there is no way we can be certain that upon releasing a new version of our application framework all the different programs will work correctly after that change without also manually retesting all these programs. Every time we release a new version of project C, we have to test program A and B as well for unintended changes. Preferably, we would move to a release system where upon releasing project C, we only have to retest program C, and not A and B for possible breaking changes that we overlooked. The idea lives to duplicate our centralised business application framework, one for each sub-project. It would mean for that when we release a new version of program C, we will provide a private version of the application framework. Upon release of program C, nothing will have changed for application A and B, they still communicate with their private application framework - so they do not need to be retested. I came up with the following pro's and con's: Con's:   * We'll have our framework hosted n times for each project    * We'll get confused in what version / project what bug is solved.   * With a major fix / change, we will have to re-release all n versions of the application framework. Pro's:   * Significantly cuts down on testing   * "Certainty" that no unintended changes are released for different projects. I must admit I am not a fan of the private copies-approach, but I fail to provide a better alternative, or better arguments against this. Has anyone been in a similar situation, and how was it handled? Is the above approach of "private frameworks copies" a solid / accepted approach? Any advice is welcomed. Thanks in advance.


Entity Framework 5, separating business logic from model - Repository?

I am working on my first public-facing web application and I’m using MVC 4 for the presentation layer and EF 5 for the DAL. The database structure is locked, and there are moderate differences between how the user inputs data and how the database itself gets populated. I have done a ton of reading on the repository pattern (which I have never used) but most of my research is pushing me away from using it since it supposedly creates an unnecessary level of abstraction for the latest versions of EF since repositories and unit-of- work are already built-in. My initial approach is to simply create a separate set of classes for my business objects in the BLL that can act as an intermediary between my Controllers and the DAL. Here’s an example class:               public class MyBuilding     {         public int Id { get; private set; }         public string Name { get; set; }         public string Notes { get; set; }              private readonly Entities _context = new Entities(); // Is this thread safe?         private static readonly int UserId = WebSecurity.GetCurrentUser().UserId;              public IEnumerable<MyBuilding> GetList()         {             IEnumerable<MyBuilding> buildingList =                  from p in _context.BuildingInfo                 where p.Building.UserProfile.UserId == UserId                 select new MyBuilding {Id = p.BuildingId, Name = p.BuildingName, Notes = p.Building.Notes};             return buildingList;         }              public void Create()         {             var b = new Building {UserId = UserId, Notes = this.Notes};             _context.Building.Add(b);             _context.SaveChanges();                  // Set the building ID             this.Id = b.BuildingId;                  // Seed 1-to-1 tables with reference the new building             _context.BuildingInfo.Add(new BuildingInfo {Building = b});             _context.GeneralInfo.Add(new GeneralInfo {Building = b});             _context.LocationInfo.Add(new LocationInfo {Building = b});             _context.SaveChanges();         }              public static MyBuilding Find(int id)         {             using (var context = new Entities())  // Is this OK to do in a static method?             {                 var b = context.Building.FirstOrDefault(p => p.BuildingId == id && p.UserId == UserId);                 if (b == null) throw new Exception("Error: Building not found or user does not have access.");                 return new MyBuilding {Id = b.BuildingId, Name = b.BuildingInfo.BuildingName, Notes = b.Notes};             }         }     }      My primary concern: Is the way I am instantiating my DbContext as a private property thread-safe, and is it safe to have a static method that instantiates a separate DbContext? Or am I approaching this all wrong? I am not opposed to learning up on the repository pattern if I am taking the total wrong approach here.


Is a code review subjective or objective (quantifiable)?

I am putting together some guidelines for code reviews. We do not have one formal process yet and are trying to formalize it. And our team is geographically distributed. We are using TFS for source control (we used it for tasks/bug tracking/project management as well, but we migrated that to JIRA) with Visual Studio 2008 for development. **What are the things you look for when doing a code review?**   * _These are the things I came up with_     1. Enforce FxCop rules (we are a Microsoft shop)     2. Check for performance (any tools ?) and security (thinking about using OWASP - code crawler) and thread safety     3. Adhere to naming conventions     4. The code should cover edge cases and boundaries conditions     5. Should handle exceptions correctly (do not swallow exceptions)     6. Check if the functionality is duplicated elsewhere     7. A method body should be small (20-30 lines), and methods should do one thing and one thing only (no side effects and avoid temporal coupling -)     8. Do not pass/return nulls in methods     9. Avoid dead code     10. Document public and protected methods/properties/variables **What other things should we generally look out for?** I am trying to see if we can quantify the review process (it would produce identical output when reviewed by different persons) Example: Saying "the method body should be no longer than 20-30 lines of code" as opposed to saying "the method body should be small". Or is code review very subjective (and would differ from one reviewer to another)? The objective is to have a marking system (say -1 point for each FxCop rule violation, -2 points for not following naming conventions, 2 points for refactoring, etc.) so that developers would be more careful when they check in their code. This way, we can identify developers who are consistently writing good/bad code. The goal is to have the reviewer spend about 30 minutes max, to do a review (I know this is subjective, considering the fact that the changeset/revision might include multiple files/huge changes to the existing architecture, etc., but you get the general idea, the reviewer should not spend days reviewing someone's code). **What other objective/quantifiable system do you follow to identify good/bad code written by developers?** Book reference: _Clean Code: A handbook of agile software craftmanship by Robert Martin_.


Can't work on real projects because I keep thinking about my side projects

I have a "real" project I'm working on to make money from, and a side project that is vastly more interesting. I'm having a problem where every time I go to work on my "real" project, all I can think about is ideas for my side project. How do you guys deal with that? Just power through the real work?


Copyright license for an open source project when copying a few files from another project

I'm working on a library which I'm releasing under the MIT License, but I plan to copy a few useful classes from another open source project which is released under the Apache license. Obviously, I'm going to leave the original license intact, and credit the original project but how does the licensing work? EDIT: What I need to know is - 1\. Is it okay for me to do this, since there will be two different licenses? 2\. Will it happen that most of my project will be under the MIT License(the code that I wrote), but those files that I copied from the other project will remain under Apache? EDIT 2: I got my answer here - How to include an apache library with my opensource code? Please vote to close this question.


How far can I drift from my original domain model and still have the benefits of an ORM?

I have the following **domain** models:               public class User     {         public int Id { get; set; }         public ICollection<Product> Products { get; set; }     }          public class Product     {         public int Id { get; set; }         public decimal Price { get; set; }     }      My User entity has a collection of Products, and no Product can be created without an User. I am using EntityFramework Code First approach, which requires me to declare the Foreign Key on my Product entity, thus changing it to:               public class Product     {         public int Id { get; set; }         public decimal Price { get; set; }         public int UserId { get; set; }     }      I dont quite like this because, from the **domain point of view** , it is not interesting to have the User foreign key shown in my Product entity. This, however, does not bring any harm to me and I can live with it. Please, mind that I am using an ORM to simplify my work, so I am okay with it to an extent. Is it okay to my **domain entities** having properties or such things only to satisfy my ORM of choice requirements?


Best practices for rotating large datasets?

[edit]Turns out there's 1.5 million records... The SQL database is taking about 17-20 seconds to run the query. Would it be best to have Java handle the joins and rearranging in that case? Since this is a web app, if multiple users are getting Excel exports, would the long queries reduce the overall performance of the site?[/edit] I have a dataset that contains roughly 70,000 records. For simplicity's sake, let's say the data currently looks like this: User ID | Question | Answer In our web application, the data needs to be rotated 90 degrees and exported into Excel, such that we have the following: User ID | Question 1 | Question 2 | Question 3 .... I think we end up with around 50 or so columns. Should the data be rearranged on the database side using pivot tables or should it be rearranged on the application side? Which solution would be the easiest to maintain? Which solution would have the greatest performance?


How important is automated testing in rapid release, non-critical (web) apps?

I think I understand the theoretical benefits of automated testing, especially unit testing. However, I'm not sure what the optimal amount of testing is when the project is a non-critical, rapidly developed (and deployed) web app with a reasonably large user base. My current reasoning goes like this:   * Most of the core functionality of our app can be manually tested in a matter of seconds. (The site is a type of search engine, so basically - run search, get results, it works.)   * Of course, there are many edge cases and options and such that could be tested, as well as unit testing of underlying logic, but if anything significant breaks and isn't caught before it's made live, we literally tend to get email from users within an hour. (Within minutes if it's a major problem, but very rarely does one of those get out.)   * So the consequence of any significant problem going live is that a few people are inconvenienced for a few minutes. Maybe some percentage of new visitors we get in that period would be lost, although the numbers should be very low since the time period is so short.   * Lower impact bugs might take longer for someone to email about - days, or even weeks depending on the severity - but they will also have less of an impact on users, so from a business perspective likely don't "matter" as much. Now, I'm not saying that excellent test coverage is useless. Of course it would be nice to catch every issue before it goes live. But in the cost/benefit tradeoff between working on tests and responding quickly to user feedback / adding and refining features, the latter seems to win. The one exception I've found is in code that doesn't directly affect the user. For example, ad serving code, or data collection. These don't directly impact the user's value from the site, so people are unlikely to let us know when they break. They will also be less noticeable in our feature testing. So I can see a strong case for well-defined unit tests there. (And from there, there ironically seems to be a spectrum where good test coverage becomes less important as features become more important, to the point where code that is critical to the site's operation doesn't really need to be tested (in a well defined manner) at all.) So my question is, am I way off base here? Is widespread test coverage and/or test-driven development optimal even in a non-critical, continuous-release environment? And if so, where am I failing in my reasoning? Or, assuming we fix bugs immediately when reported, is it reasonable to focus on rapid, nimble development, knowing that our users will let us know if we break something? (With the exception that we will have formal tests for functionality that is not directly exposed to the user.)


Is it necessary to memorize every line of code when it comes to game development?

I am currently following along a youtube tutorial here and from what I understand we are starting out by creating an engine to run the game. Should I be able to implement all of this by myself without outside help in the future or should I just make sure to have an understanding of everything that is going on? Would a professional game developer know how to implement everything that it takes to make a game or would he/she just copy and paste certain parts (like creating a buffer, or fps cap) and edit it to their taste?


What keywords are important to speedup the code in C++?

I'm porting to C++ and adding a lot of functionality to a numerical application written in Fortran 77. While I hate F77, I have to admit that the thing goes very fast. Now, I'm implementing practically the same structure and algorithm, but nevertheless the difference in the execution time is noticeable. Not big, but it's there. And I'm wondering, could it be that I need to pass extra information to the compiler? The only related information that I've been able to find is a recommendation to use the **restrict** key word which is supported by g++, but that's all. Hence, my question: Are there anymore keywords important to speedup code in C++ in numerical applications? or maybe compiler directives? Thanks!


Logging asynchronously - how should it be done?

In many of the services I work on there are a lot of logging being done. The services are WCF services(mostly) which use the .NET EventLogger class. I'm in the process of improving these services' performance, and I got to think that logging asynchronously would benefit performance. I'm unaware to what happens when multiple threads ask to log, and it if creates a bottleneck, but even if it doesn't I still think that it shouldn't interfere with the actual process being executed. My thoughts are that I should invoke the same log method I call now but do so using a new thread, while continuing with the actual process. **Some questions about that:** Is it ok? Are there any downsides? Should it be done in a different way? Maybe its so fast that it doesn't even worth the effort?


What is the reason for creating the symbols ∞ on the client side?

Take a look at this link: http://math.stackexchange.com/questions/60766/what- is-the-result-of-infinity-minus-infinity What is the reason for transforming the symbols ∞ on the client side? Because if someone disable javascript, this is what they see: ![enter image description here](http://i.stack.imgur.com/NXTKY.png) So right now I'm pondering what may be the reasons for that decision _(I was thinking there are bound to be some advantage otherwise the decision wouldn't have been done)_.


How to handle technological "Dogmatism"

I left a job (to relocate to another country) where I programmed in Javascript and Haskell (some python) most of the time. I really liked it because people were objective, positive, mathematical, and yet got a bunch of stuff done. This was a truly professional shop. Now I work at an Agile/XP shop. While this is good and all I feel that maybe we are unprofessional when it comes to the selection of technologies and libraries. I feel that our approach to writing software is a bit immature and unstructured. I am trying to read the books I have been offered and they seem to encourage this style ( _ugh_ ). A lot of times we just pick libs off of git hub and use it without any type of review. I get forced to work with someone all the time even if it's a small task for one person. There seems to be a little "fast" rule for everything even if the rule can be broken by a trivial counter example (one time I made the mistake of giving that counter example and I was verbally attacked). Is this normal here in the states? How do I handle this dogmatism?