title: Code duplication with no obvious abstraction

text: Have you ever encountered a case of code duplication where, upon looking at the lines of code, you couldn't fit a thematic abstraction to it that faithfully describes its role in the logic? And what did you do to address it? It is code duplication, so ideally we need to do some refractoring, like for example making it its own function. But since the code doesn't have a good abstraction to describe it the result would be a strange function that we can't even figure out a good name for, and whose role in the logic is not obvious just from looking at it. That, to me, hurts the clarity of the code. We can preserve clarity and leave it as it is but then we hurt maintainability. What do you think is the best way to address something like this?


title: What kind of questions and processes do you ask yourself and follow when designing software?

text: I've read books on design, I troll the internet for articles on best practices and software design principles. However, I always seem to struggle to put into practice the kind of suggestions and techniques supplied. My question is. What kind of things do you ask yourself when you are designing an application/class/method location/property location etc that helps ensure you come up with something that is, although not perhaps perfect, is good enough that you are happy with the result. For example, when trying to decide between putting a property on an object how do you decide whether the code that might use that object should be part of the class that contains it or exposed so other classes can use it. i.e. how do you decide who owns and responsible for a certain logic/property. I realise there are things like SOLID that you can apply, but I'm looking for techniques and thought processes people often go though in order to get to the end design that applies these principles. NOTE: I'm not looking at getting links to books or internet articles necessarily as these I look at quite regularly. I'm really after peoples read world practices on how they go about day to day resolving class and application design issues they come across. Thanks alot.


title: Are there technical reasons for an immediate update following a fresh download/install?

text: I've had this happen in all sorts of software products: You purchase a software product, download it, install it, and then after the install, the program immediately begins downloading an update or a patch. Ideally, I would imagine that the download package would somehow be linked to the product's repository so that stable releases could be pushed to the product site rather than having to force the user to wait through an update after install. Are there any technical reasons for the install/update process or is it just a case of poor deployment infrastructure on the part of a lot of companies?


title: Choosing a JavaScript Asynch-Loader

text: I’ve been looking at various asynchronous resource-loaders and I’m not sure which one to use yet. Where I work we have disparate group-efforts whose class-modules may use different versions of jQuery (etc). As such, nested dependencies may differ, as well. I have no control over this, so this means I need to dynamically load resources which may use alternate versions of the same library. **As such, here are my requirements:**     1. Load JavaScript and CSS resource files asynchronously.   2. Manage dependency-order and nested-dependencies across versions.   3. Detect if a resource is already loaded.   4. Must allow for cross-domain loading (CDN's)   5. (optional) Allow us to unload a resource. **I’ve been looking at:**     * Curl   * RequireJS   * JavaScriptMVC   * LABjs I might be able to fake these requirements myself by loading versions into properly-namespaced variables & using an array to track what is already loaded...but (hopefully) someone has already invented this. **So my questions are:**     * Which ones do you use? And why?   * Are there others that my satisfy my requirements fully?   * Which do you find most eloquent and easiest to work with? And why? **UPDATE:**   For those interested, I tried all the AMD libraries above (and more). In the end, I went with RequireJS. It's just cleaner and easier overall...and I'm glad to be using it.


title: Why does Facebook use hash in the URL...sometimes?

text: I've noticed that Facebook SOMETIMES uses a hash in the url. For example, when I'm on my home page, and then I click my profile page, the URL quickly changes to:               facebook.com/#_________      followed by some other stuff. before quickly loading to:               facebook.com/profileName      It doesn't always do this. What's going on here?


title: Is state pattern a good solution for implementing UI changes for Landscape and Portrait modes?

text: For our iOS app, a lot of complicated UI logic depends on the interface orientation of the ViewController. This conditional logic is present in a lot of places. Can it be segregated into different states in form of objects?


title: What is a good workflow for a C++ beginner?

text: I desire to become a more serious scientific C++ programmer. To do so, I need a consistent style of workflow (e.g., coding, test-driven development, etc.). My question is simply what sort of workflow should I consider? I am familiar with Linux and Mac, and prefer to use free tools like cppcheck, valgrind, g++, etc. I prefer to use Qt and Boost within my programming toolbox, and I am considering using mock objects (either Google Mock or MockPP) within the TDD. I typically use vim for my editor. In essence, should I do something like the following: > TDD -> code -> cppcheck -> valgrind -> debug -> repeat until ready to use > profilers and coverage mechanisms or, should I pursue some other way? I realize that the opinions will vary, and I also understand that I must first take the time to think through the process and document my thoughts whether written or UML before coding, and I also know that I should document the code as I step write the code. Any and all thoughts will be appreciated.


title: Is 4-5 years the “Midlife Crisis” for a programming career?

text: I’ve been programming C# professionally for a bit over 4 years now. For the past 4 years I’ve worked for a few small/medium companies ranging from “web/ads agencies”, small industry specific software shops to a small startup. I've been mainly doing "business apps" that involves using high-level programming languages (garbage collected) and my overall experience was that all of the works I’ve done could have been more professional. A lot of the things were done incorrectly (in a rush) mainly due to cost factor that people always wanted something “now” and with the smallest amount of spendable money. I kept on thinking maybe if I could work for a bigger companies or a company that’s better suited for programmers, or somewhere that's got the money and time to really build something longer term and more maintainable I may have enjoyed more in my career. I’ve never had a “mentor” that guided me through my 4 years career. I am pretty much blog / google / self taught programmer other than my bachelor IT degree. I’ve also observed another issue that most so called “senior” programmer in “my working environment” are really not that senior skill wise. They are “senior” only because they’ve been a long time programmer, but the code they write or the decisions they make are absolutely rubbish! They don't want to learn, they don't want to be better they just want to get paid and do what they've told to do which make sense and most of us are like that. Maybe that’s why they are where they are now. But I don’t want to become like them I want to be better. I’ve run into a mental state that I no longer intend to be a programmer for my future career. I started to think maybe there are better things out there to work on. The more blogs I read, the more “best practices” I’ve tried the more I feel I am drifting away from “my reality”. But I am not a great programmer otherwise I don't think I am where I am now. I think 4-5 years is a stage that can be a step forward career wise or a step out of where you are. I just wanted to hear what other have to say about what I’ve mentioned above and whether you’ve experienced similar situation in your past programming career and how you dealt with it. Thanks.


title: using "IS" is better or checking for "NOT NULL"

text: In C#.NET language: This style of coding is recommended or the one below it?                       if (sheet.Models.Data is GroupDataModel)             {                 GroupDataModel gdm = (GroupDataModel)sheet.Models.Data;                 Group group = gdm.GetGroup(sheet.ActiveCell.Row.Index);                    if (group!=null && controller != null)                 {                     controller.CheckApplicationState();                 }             }      or this one:                       var gdm = sheet.Models.Data as GroupDataModel;             if (gdm != null)             {                 Group group = gdm.GetGroup(sheet.ActiveCell.Row.Index);                    if (@group!=null && controller != null)                 {                     controller.CheckApplicationState();                 }             }


title: WinRT for 'desktop' apps

text: So I'm reading up about the differences between the old and the new APIs, and I can't find whether the new WinRT API will provide for desktop apps, so far it seems its only available to write Metro apps - ie the full screen, 'phone style' apps. Does this mean that I can write a WinRT-based app and it will be invoked from a desktop but display like other Metro apps (eg IE) and I won't be able to write an old-style desktop app that runs in the old-style desktop? What does this mean for server side apps? I imagine WinRT would be the API of choice for servers, now that Windows Server comes with an optional GUI, so I imagine that if I can write a windows-less app using WinRT for the server, I should be able to write the same for the client too? (and if that's the case, surely I could connect a non-Metro UI to it)


title: Run coded UI tests on different projects

text: With little or none previous experience of testing, I'm looking into adding automated testing to a continuous integration process of SharePoint applications. I've learned how this can be achieved using coded UI tests that are run before deployment and during the build and I've used Selenium with Java before, where we didn't record any scenarios but instead wrote tests by hand, identifying elements in the GUI and asserting results. With this little experience, I have a few questions about UI testing.   1. Is it possible to write test methods that can be applied on several different applications, such as testing buttons etc. or is this something that has to be written for each project, since the results of button click may vary? I assume that this would require following a specific standard .   2. Are there any UI testing methods that can be generalized and applied to all projects that go through a certain build, or is the same here that all UI tests must be written specifically for that application?


title: Should exceptions do things other than tell the user something went wrong?

text: I created a general class that accepts a string when it is constructed, and it spits out that string when a user calls what(). This is all it does; on throw, it returns the initializing string.               class Exception_As {       private:           std::string message       public:           Exception_As(const std::string& message) { // constructor             this->message ="EXCEPTION: " +message;         }              virtual const char* what() const throw() {             return message.c_str();         }     }      How I use my custom exception class:               bool check_range(           const std::vector<std::string>& list,         const unsigned& idx_start,  // where to start checking         const unsigned& idx_end,    // where to stop checking         const std::string& key     ) {         if ( idx_start > idx_end ) {             throw Exception_As("check_range: start index > end index: now fix it! :D");         }              ... rest of code     } // end of check_range      How a user would use check_range:               // some other user code using my check_range     void main() {         try {             ... set up variables                  my_hero_qualified = check_range(semi_finalists, third_place, first_place, my_hero);             ...rest of code         }              catch (const Exception_As& e) {             std::cout << e.what() << std::endl;         }     }      If the try/catch was not there, it would abort the program because of the thrown Exception_As. If it was there, the user would be notified that "check_range: start index > end index: now fix it! :D". For me, sure beats writing tons of BadEvent1Exception, BadEvent2Exception, etc classes. I can see I'm being lazy with this method, and yeah, I can't do anything fancy like modify values based on exceptions or morph an object's state; but if you just entered unexpected territory, who knows if you're handling it correctly? May as well just end it so you can fix what's up and develop properly. So, question: if all exceptions do is break the program on unexpected circumstances, won't a single exception class that returns the problem be enough? ...Or should exceptions be doing other things anyway? If not, why create so many classes of Exceptions that have different names, sure, but from what I've seen, only report that something went wrong.


title: How to divide OO project into packages?

text: I'm a hobbyist programmer working on my own projects. I use Java. Until recently my average project was only 1000 LoC. My latest project however is bigger and is starting to exceed 1500 LoC. I estimate it will reach about 2000. I've never organized my classes into packages. All of them were always in the default package and it worked fine. However as my projects grow and the amount of classes gets bigger, I'm starting to feel unorganized. My question is: how exactly does one divide his/her classes into packages? What I mean is, by what criteria do you divide classes? **Is it by the 'part' of the app?** Aka GUI classes in one package, business logic in the other, networking, etc.? **Or maybe high-level classes versus lower level classes?** Aka classes that do concrete, specific work in packages of their own, and 'architectural' classes that tie it all together in their own packages? **Or maybe you simply divide by the criteria of 'what feels right and organized' specifically to you?** For example, I'm working on an app that makes music. It is basically divided into two main systems: the system that makes the music, and the system that displays the GUI and controls the other system (i.e. a button press in that system activates the other system). The music-creation system is also divided into two systems: for creating melodies and for creating chord progressions. And the chord-progression generation part, among other things contains a group of classes that serve as interchangable algorithms for a Strategy pattern involved (i.e. classes used for a specific implementation detail). There are of course higher-level and lower-level classes involved in every system. For example the progression-generation system contains a `ProgressionGenerator` class, which is high-level and ties the entire system together. It also has a `Chord` class which is far more low level (i.e. takes care of playing specific notes). The way I would organize this into classes is like so: The music-creation system into one package, the GUI system that controls the other system into another package. Than the melody-creation into a subpackage of the music-creation pakcage and the progression-creation into a different subpackage. And inside the progression-creation subpackage, another subpackage contataing the classes used for that Strategy pattern involved somewhere in that system. **Does this sound like a good approach for organizing things into packagages? By what criteria do you divide the classes into packages? By 'what feels right', or by more technical terms?**


title: Moving from one man project to team project in the future. What should I be doing now in preparation and what can wait?

text: To elaborate I am interested in knowing what people think you need to put in place while still a one man project (team source control, documentation, builds etc) and what things don't need to be done until that point when the second person comes onto the project. Anyone with any experience of moving through this scenario, their insights will be appreciated.


title: "Software features that can't be demonstrated by automated tests simply don't exist"-- Is it too extreme a statement?

text: Kent Beck famously said that > Software features that can't be demonstrated by automated tests simply don't > exist But is this too extreme? I mean, I can't demonstrate that my UI really works, the screen pixel is correct in automated tests. So my features don't exist?


title: Script/tool to import series of snapshots, each being a new edition, into GIT, populating source tree?

text: I've developed code locally and taken a fairly regular snapshot whenever I reach a significant point in development, e.g. a working build. So I have a long-ish list of about 40 folders, each folder being a snapshot e.g. in ascending date YYYYMMDD order, e.g.:-   1. 20100523    2. 20100614   3. 20100721   4. 20100722   5. 20100809   6. 20100901   7. 20101001   8. 20101003   9. 20101104   10. 20101119   11. 20101203   12. 20101218   13. 20110102 I'm looking for a script to import each of these snapshots into GIT. The end result being that the latest code is the same as the last snapshot, and other editions are accessible and are as numbered. Some other requirements:   * that the latest edition is not cumulative of the previous snapshots, i.e., files that appeared in older snapshots but which don't appear in later ones (e.g. due to refactoring etc.) should not appear in the latest edition of the code.   * meanwhile, there should be continuity between _files_ that _do_ persist between snapshots. I would like GIT to know that there are previous editions of these files and not treat them as brand new files within each edition. Some background about my aim:   * I need to formally revision control this work rather than keep local private snapshot copies.   * I plan to release this work as open source, so version controlling would be highly recommended   * I am evaluating some of the current popular version control systems (Subversion and GIT) BUT I _definitely_ need a working solution in GIT as well as subversion. I'm _not_ looking to be persuaded to use one particular tool, I need a solution for each tool I am considering. (I haved posted an answer separately for each tool so separate camps of folks who have expertise in GIT and Subversion will be able to give focused answers on one or the other). The same but separate question for Subversion: Script/tool to import series of snapshots, each being a new revision, into Subversion, populating source tree?


title: Javascript - Avoiding variable redundancy in nested for loops

text: **Please bear with me, I could only explain the problem in the comments of the code snippet below. Please read through them carefully. Question at the end:** I usually tend to name the variables used in `for` loops with `i`, like this:                for (var i = 0; i < arr.length; i++){           // do some COMPLEX operations here      }      This looks fairly simple; but when I'm at it I may require nested for loops within the above `for` loop. So, introducing the complexity now:                for (var i = 0; i < arr.length; i++) {           // do some           // VERY           // COMPLEX           // operations           // here                for (var i = 0; i < javascript_object.list.length; i++) {               // I may have inadvertently forgot of the variable 'i' was been used earlier               for (var j = 0; j < javascript_object.list[i].another_list.length; j++) {                   // Perform more complex operations here               }           }                this.getReports(arr[i]) // the value of this i              // which I now think refer to the first for loop might have been changed              // in second for loop and may lead to dangerous results!       }      How to avoid this from happening? How could the variables be named carefully so that it wouldn't clash with other variables being declared elsewhere?


title: How does Mercurial determine which changesets I need when I pull?

text: This is a question about the internal workings of Mercurial. I vaguely remember a fellow programmer explaining to me how mercurial works out which changesets differ between two repositories and that it had a speedy solution to the problem. Does anyone know how this works or can point me towards a document describing the details?


title: Testing ASP.NET .aspx and .ascx code behind files

text: I am wondering how to test .aspx.cs and .ascx.cs code behind. Can I use unit testing and if so how? Are there alternatives that will help test the functions in the code behind files? I don't know how to mock the page or control. I would like to try to apply tdd methodology but I don't know how to unit test the code behind. Do you setup tests for the code behind or move the code to alternate files that are easier to test. Is moving the code out of the code behind a better practice? Also, how would you go about unit testing the code behind files?


title: How granular should a command be in a CQ[R]S model?

text: I'm considering a project to migrate part of our WCF-based SOA over to a service bus model (probably nServiceBus) and using some basic pub-sub to achieve Command-Query Separation. I'm not new to SOA, or even to service bus models, but I confess that until recently my concept of "separation" was limited to run-of-the-mill database mirroring and replication. Still, I'm attracted to the idea because it seems to provide all the benefits of an eventually-consistent system while sidestepping many of the obvious drawbacks (most notably the lack of proper transactional support). I've read a lot on the subject from Udi Dahan who is basically _the_ guru on ESB architectures (at least in the Microsoft world), but one thing he says really puzzles me: > As we get larger entities with more fields on them, we also get more actors > working with those same entities, and the higher the likelihood that > something will touch some attribute of them at any given time, increasing > the number of concurrency conflicts. > > [...] > > A core element of CQRS is rethinking the design of the user interface to > enable us to capture our users’ intent such that making a customer preferred > is a different unit of work for the user than indicating that the customer > has moved or that they’ve gotten married. Using an Excel-like UI for data > changes doesn’t capture intent, as we saw above. > > \-- Udi Dahan, Clarified CQRS From the perspective described in the quotation, it's hard to argue with that logic. But it seems to go against the grain with respect to SOAs. An SOA (and really services in general) are supposed to deal with _coarse-grained messages_ so as to minimize network chatter - among many other benefits. I realize that network chatter is less of an issue when you've got highly- distributed systems with good message queuing and none of the baggage of RPC, but it doesn't seem wise to dismiss the issue entirely. Udi almost seems to be saying that _every attribute change_ (i.e. field update) ought to be its own command, which is hard to imagine in the context of one user potentially updating hundreds or thousands of combined entities and attributes as it often is with a traditional web service. One batch update in SQL Server may take a fraction of a second given a good highly-parameterized query, table-valued parameter or bulk insert to a staging table; processing all of these updates one at a time is slow, slow, _slow_ , and OLTP database hardware is the most expensive of all to scale up/out. Is there some way to reconcile these competing concerns? Am I thinking about it the wrong way? Does this problem have a well-known solution in the CQS/ESB world? If not, then how does one decide what the "right level" of granularity in a Command should be? Is there some "standard" one can use as a starting point - sort of like 3NF in databases - and only deviate when careful profiling suggests a potentially significant performance benefit? Or is this possibly one of those things that, despite several strong opinions being expressed by various experts, is really just a matter of opinion?


title: Algorithm for Testing interoperability

text: I am writing a php script that carries out a task. One input is a list of options that I need to test for interoperability. If the options are `A B C` then I need to test every combination, but I only keep the options that are compatible ("left to right") and throw away the ones that are not to get a final Result (R).   * A is compatible with B? -> Result   * R with C? -> R rather than:   * A is compatible with B?    * A with B?    * A with C?  The options might be provided in any order but I don't want to bother with the cost of sorting them first. My "left to right" rules imply that the first valid option found dictates compatibility going forward. So `A B C` could mean a different R than `B A C`. Also The options might be interspersed with invalid options. For example `A 0 C` The way I am solving this right now is as follows:   * I stored a predefined list `l` of possible option names with details about the option. Each option has the following static details:      * information about which options it is compatible with ** (starring this as we'll come back to it)     * details about how to implement it     * an index number, `i` ( by definition of it's storage) `l` might look like this (written as JSON for readability here):               { A : { "description"    : "some text to help out",             "index"          : 0,             "conflict"       : (1 << 1 | 1 << 3),             "implementation" : doA()           },       B : { "description"    : "some text to help out",             "index"          : 1,             "conflict"       : (1 << 0 ),             "implementation" : doA()           },     ...     }      When I'm given a list of options the algorithm is this:   * while options      * if option `o` is in the list `l`       * then keep it and find it's index `i` and compatibility "mask" `l[i][m]`       * update the aggregate compatibility "score" `m`       * update the aggregate conflict "score" `c`     * else throw it away for an given `l[i]` it's `m` (`l[i][m]`) is always an integer that represents an item's known compatibility with other items. It is not an array, but rather `m = 1 << i(X) | 1 << i(Y) | 1 << i(Z)` where it is compatible with `X` via it's index, meaning "index of X". So we can rewrite the algorithm more specifically as (still pseudo-code):               for options as o         _m = 1 << l[o][i]         _c = l[o][c]         if( !( _m & c )  && !( m & _c ) )             m |= _m             c |= _c      I'm pretty happy with it right now but since I'm new to using binary operations in a practical way I'm **uncertain as to it's re-use, especially maintenance with a large number of options**. Right now the biggest challenge is that when a new option is added I have to go through all the options to determine if its compatible and update the conflict values. If I get more than a couple of dozen options I may have to use option groups where anything in group must be fully compatible with that group but other groups might be compatible with this group and not share the same compatibility with other groups. I'm also concerned with **readability** for whomever comes after me. Implemented differently, the conflict values might just be a list of items `[A, C, ...]`. But that seems like extra overhead to me and even though conflict values are integers, the raw form of the conflict values directly lists those index values it is in conflict with. e.g. `1 << 1 | 1 << 3` means it is in conflict with whatever is at index 1 and and whatever is at index 3. So I hope that mitigates some of the readability issues. The good things that I see are:   * should be fairly performant   * easy to test new options. I have methods that will give you a sanity check of any options you ask about giving compatibility and conflict lists.    * good for debugging. I simply spit out a combined strategy number into a log and in a compact form I can see what the compatibility choices made were. Small enough I can even put that info into a terse production log as a "code value" **Thoughts?** +1 if you like it. Answers /comments if you have constructive criticism or feedback please side note: To be honest I don't really care about performance here because the task only happens once a day in the middle of the night, but I'm interested in the problem itself and I'm sure this will help me become a better programmer.


title: Domain Name Lookup

text: I'm trying to automate the process of sending many domain name lookup requests. I tried to do this by sending for example http request to domain registry site like Whois.net, but I notice they block you after several attempts. others like networksolutions adds token to the page to avoid automated requests. Is there any ideas please? I'm using Java.


title: What is the difference between system analysis and system requirement analysis

text: Are "system analysis" and "system requirement analysis" the same thing? I think system system analysis is broader term and system requirement analysis is part of it. Is this correct?


title: Adding ordered nodes to tree in arbitrary order

text: I have a database of nodes. Each node can have exactly one parent, but any number of children. Some nodes may be stored with no parent, but at run time, I can create a default "root" node to be the parent of these. First off, what is this data structure called? I think it's just a "tree," but I want to make sure I'm using the correct terminology. Another issue I'm running into is finding an efficient way to create the tree. The nodes can be retrieved from the database in any order, so when I add a node to the tree, its parent may not be in the tree yet. This means that when I add a node, I have to check whether any existing nodes have parents and then add the parent in the appropriate spot. I've searched a lot online, but most talk about trees just refers to "binary trees," and even then I can't even find any good examples of constructing the tree in code -- it's usually working with an existing tree. Are there any examples of efficient ways to build this tree (whatever it may be called)? Language doesn't matter, but I'll be using php.


title: Two different user story forms, are both correct?

text: **Just ran across this user story form:**               "As a <user role>, I can <activity> so that <business value>"      (source-1 and source-2) **which to me seems different than what I believe to be the "standard" one:**               "As a <role>, I want <goal/desire>, so that <benefit>"      (source-1 and source-2) (Meaning that I'd believe "I can" would be in the "benefit/value" statement, not the "goal" statement. For example, "So that I can [...].") **Are both right, or is one flawed, and why?**


title: Is it possible to share oAuth Session?

text: We are working on a project that includes a web server and a mobile application, we need to access the user's private data (facebook, twitter ...) from the web server by requesting from the user to authenticate our app using the mobile. I managed to access the user's private data from the mobile easily after the user has authenticated the app. now how can I propagate/share this privilege with the server, so that the server can access the user data anytime and work on it ? A typical use case for example:   * user install our mobile app.   * user registers for a direct messages counter service (dummy service).   * user authenticate our app to access his twitter account on the mobile.   * server starts daily pinging the twitter apis and get some data about the user.   * server publish the results to the mobile app. is this scenario possible ? if so where should I be looking to make it happen ?


title: What is the future for ASP.NET Membership Providers?

text: While working on a new project with MVC3, a DI framework (Ninject), and unit tests (NUnit) paired with mocks (Moq), I found setting up the Membership Provider felt a bit "awkward". I've run into tasks that seem disproportionally hard, just as others have: injecting a repository to the provider, creating unit tests, and mocking the provider. This led me to a SO question on alternatives to the standard Membership provider (in turn linking to another interesting question on whether to roll your own authentication system), which didn't get as much attention as the votes on the question would warrant. So I'm finally left with **the question** : _Does anyone know what the future for Authentication in ASP.NET is? Or more specifically: did Microsoft provide any (official) insights on their direction for authentication?_ I couldn't find any blog posts from MS employees/teams. The only real related thing I could find was this highly upvoted ASP.NET uservoice ticket which doesn't seem to have any official response.


title: Is it better to teach conditional loops or iterative loops first?

text: I've seen tutorials and textbooks that teach conditional loops (while) first and I've seen others that teach iterative (for) loops first. Have there been any studies done as to which produces better results as far as student learning or is it a matter of personal taste?


title: Host an MVC 3 with Razor syntax app on old server

text: I just started a new job, I have to create a web app for them and host it on their intranet on an Windows 2003 R2 server with SQL server 2008. As said in the question, I'll work on a MCV3 with Razor syntax application. I know that it won't work easily or even not work at all. On a recent server you have to install something more (I don't remember the name) for the Razor to be understood. What about on this old server? Will I get it to work or should I tell them to buy a more up to date server?


title: How can I explain object-oriented programming to someone who's only coded in Fortran 77?

text: My mother did her college thesis in Fortran, and now (over a decade later) needs to learn c++ for fluids simulations. She is able to understand all of the procedural programming, but no matter how hard I try to explain objects to her, it doesn't stick. (I do a lot of work with Java, so I know how objects work) I think I might be explaining it in too high-level ways, so it isn't really making sense to someone who's never worked with them at all and grew up in the age of purely procedural programming. Is there any simple way I can explain them to her that will help her understand?


title: Do you count a Masters in CS as a negative?

text: In my experience interviewing developers I feel like candidates who've achieved a Masters in Comp Sci tend to be **worse** programmers on average that those who don't have a Masters. Is that just me, or have others noticed this phenomenon? If so, why would that be the case? **UPDATE** I appreciate the thoughtful comments. I think I should have been clearer in the comparison I'm making. Given two candidates who graduated from college around the same time, someone who went on to gain a Masters seems on average to be a worse programmer than someone who spent all their time in industry.


title: Data Transfer Best Practices

text: At my company we have some vendors that we transfer data to and from. Sometimes the data is pulled into our local SQL database for business reporting. Other times we pull data from one vendor, transform it, and then transfer it to another vendor's FTP server. The guy I replaced has a couple of generic SFTP Push/Pull console applications that transfer data to/from these vendors. Then he has other applications that do the data imports to the SQL database or transforms the data and leaves it out in a directory to be pushed to the vendor. Every once in a while we will have problems with these processes not finding the file needed and I have to go back and run these manually to load the data. It seems to me that it would be more reliable if these processes just did their own FTP push/pull functions so we don't run into scheduling problems. Are there any standard practices that I can implement that would be more reliable or do I need to just _tweak_ what I have now? I'm in a Windows/.NET environment by the way.


title: Are Interfaces with Java 8 Virtual Extension Methods the Same Thing as Mixins?

text: This post describes a new feature in Java 8 called virtual extension methods (formerly called default methods, or defender methods). In the example provided, an interface has one method, which is implemented by a class. Then a second method is added, but instead of forcing the class to immediately implement the interface's new method, a "virtual extension method" is created within the interface as an implementation of this new method, thus the class doesn't need to implement the new method right away. But say that the programmer decides to create a virtual extension method in an interface and never plans to have subclasses implement its own version. Wouldn't that be a mixin? It seems like one to me, but I've never heard it referred to as such. Is there some fundamental difference that I'm not understanding?


title: How does Google store search trends in backend?

text: Google trends shows what query has been searched how many times and some other properties of the said query. But how is this data stored in a database? Storing a new row for every search does not seem right. They also tell the query on a time graph, so they must have some way to look for individual searches made by users, but the number of queries they get every day, it does not feel right that they would store every search in a database row along with a time-stamp. This does not apply to just Google trends or Google in general but any other big site that gets awful number of queries and then has tools to see them in depth. I am not an expert on this but I am interested to know some high level structure of how things work behind the scenes.


title: I would like to contribute my time for free to a Ruby open source project, what are some beginner friendly Ruby projects?

text: I think I am at a point where I can truly contribute to a Ruby open source project, can you suggest one or more that would be open to having a true beginner contribute. This would be my first group project where I would like to be 'mentored' or something similar by a more experienced coder. I would be able to work in my free-time and for free.


title: Erlang or 'x'.. Is it worth it (vs. Python w/ GIL)?

text: So, I've finally gotten myself to a point where I'm comfortable enough with Python (using Pyramid as my framework of choice) to undertake a rather large personal project. As it's a personal project, I have the luxury of taking my time having absolutely no deadlines other than self-imposed ones. I love learning new frameworks, languages, etc. so if given a reason, I don't mind pushing back on development for a month or so while learning a new language and framework (takes longer when you're doing it on your own time ;)). I recently learned about CPython's GIL (Global Interpreter Lock), which raised my eyebrow a bit. If I understand it correctly, this means that if I have a `Queue` in my web app and have threads that complete jobs in the queue, then the code is locked until the thread for that request is complete, meaning that any subsequent request is locked while the previous thread is executing. **Question:** Has anyone in "real world" applications found this to be a problem? Is it worthwhile to learn a language that supports _real_ concurrency out of the box, such as Erlang? I'm most interested in any benchmarks that anyone has done in real world apps and whether or not anyone has seen any real noticeable issues with the GIL.


title: What advice would you give to someone going freelance?

text: I'm trying to get out of the Corporate game and go indie. I've always prided myself on being a jack of all trades so I think it suits me. If you're a freelancer or independent, what's the best advice you could give me as I start down this road?


title: How can proprietary code be protected when collaborating with an external company?

text: Imagine I have a code base and I'm obsessively concerned about the protection and privacy of that code. If I were to hire a freelancer to work on that code base, I'd probably have the freelancer sign a nondisclosure agreement and hopefully I'd build up a relationship with him/her over time and gain some confidence that he/she can be trusted. However, if I wanted to collaborate with an external company, company X, what steps can I take to protect my code? I assume a nondisclosure agreement would offer some protection in the case that company X steals my code, but what could I do to protect against the code being stolen from a rogue company X employee with access to the code base? Should I require that all employees at company X sign a nondisclosure agreement? In general, what steps can be taken by a company like company X to encourage a trusting collaboration with their clients? How can company X assure me that the code they have access to won't be stolen? Are such collaborations even possible? **Postscript:** I'm not really confident in the protective power of most non-disclosure agreements. In general, I believe that all I can do is work with people that I trust and hope for the best. However, for the purposes of this question I'm interested in hearing if _any_ form of protection is available even if it isn't particularly robust.


title: Best practices in Application's flow diagram

text: I make web applications, mostly MVC, object oriented and database enabled. I always have trouble going back to project after a few months of release and work again. I don't even remember what I made on that project. How should I overcome this problem? I can't afford too much time consuming documentations and so many diagrams. Any quick way you guys practice to avoid this?


title: How to properly structure a collection of immutable constants

text: I'm in the design stages of a program that based upon input received, would select a particular category, and action within that category. The category, the action within in, and the value(s) related to that action are all immutable values, along with the relationship between category and action. Normally I'd just assign it all into a multidimensional array or collection, but that strikes me as both messy and unnecessarily complex to search and sort. Constants don't allow me the luxury of defining relationships between them (aka you can't have constant A bound to subConstant B for example), and being a desktop app, having a user setting up a database server isn't appealing. Was thinking of having everything in xml files, but core rules of the application isn't appealing due to being able to easily edit, and hence change the primary functionality of the program that I wouldn't wish to be editable. Anyone ever ran into something like this, and if so, what was the setup that you used for your solution? EDIT: Let me see if I can explain this better with an example. Say I have the following structure               category A       -- action AB           -- result 1           -- result 2           -- result 3           -- result 4           -- result 5           -- result 6      where if I selected category A, and action AB, a one dice roll would select the result to be returned. The category, action, and result will never change both in name and in relationship (action AB will always be bound to category A, results within action AB will be bound to action AB, and the result contents will never change) EDIT: No network usage would be expected for this application, as it was asked in one of the responses.


title: Legality of collaborative reverse-engineering

text: I have been disassembling a large software project on my own, as a hobby. It is an educational exercise and I have learned a lot in the process. That said, I feel that my progress would be considerably quicker if I was to collaborate on the project with other like-minded individuals. Herein lies the problem -- maybe. I am reversing this software for personal interest and potentially (but unlikely; given the magnitude of the codebase in question) implementing an interoperable service to interact with this software, replacing the vendor's own service. My (very limited) understanding is that this particular use-case is protected under copyright law. However, my wish is to collaborate with others freely on the Internet, in a similar system employed by open source projects: version control repositories of assembly files, wikis to coordinate and share knowledge, public mailing lists, et cetera. I have a feeling this may be iffy at best. Is what I want to do blatantly illegal, a gray area or even legally defensible? Would the situation be any different if the collaboration was in private rather than public? If it has any bearing on the answer, I am located in Australia and the software vendor in located in the USA.


title: Should I use AND or should I use OR

text: An order can be in the "status" of Completed, Corrected or some other status. I saw some code that is checking it like this, the purpose is to disable some stuff when the status is in Completed or Corrected status.                if (model.CurrentStatus != DSRHelper.OrderStatusEnum.Complete && model.CurrentStatus != DSRHelper.OrderStatusEnum.Corrected)      I can't get it why the engineer has used "AND" for this, shouldn't it be an "OR"?


title: What kind of programs/solutions can only be written with OOP or are too hard to achieve without it?

text: Paraphrasing a recent question: What is Object Oriented Programming ill-suited for? I would like to ask the opposite question: What kind of programs cannot be written unless you use OOP?   What kind of programs are not recommended to be written using non-OOP techniques?   What kind of programs need OOP in order to even be written? What kind of programs would be too hard to write without OOP ? The answer to this question can help sell the idea of OOP to project leaders that have no special interest in code quality. At least they could buy the idea if one shows them the kind of things that are not even possible unless you use OOP.


title: Inventory / Stock in multiple locations

text: I am working on a warehouse management system (WMS) that needs to support having stock in multiple locations. Could be in a different building, could be stored in n* places in a building (quick example would be stock, overflow, or fast moving slots all containing a qty of the same item). Where I am, they have always used one SKU assigned to one bin with paper notes pointing to overflow. Obviously they have grown beyond this and it's causing some serious issues. No one here can help me when I try to get what the best practice should be. I am having trouble conceptualizing how to setup the structure. I am thinking ...   * Warehouse (virtual or physical) Warehouses can belong to warehouses.   * Location - Anything really could be a pallet, box, or just a taped off area on the floor. Locations belong to warehouses.   * Rows - can be in locations   * Shelves can be in rows   * slots(traditionally called a bin here) the smallest unit that can be a location. Then a SKU could be in any one or many of these locations (except the virtual warehouse - used only from grouping physical locations but allowing a sales order to process them internally as if it shipping from one space). Locations (are their children) could be given priority. So if a SKU is in 2 locations, the systems knows which slot(bin) to empty first before routing to the next. I code it so that the structures above can be handled by the warehouse since i don't care physically about them only that the process makes sense and then give them a tool to mark a sort order so that they can determine the best routes through the warehouse with batch picking an order. I guess I just wanted to get this out of my head and get someone elses eyes on it before I wrote a single line of code. Does this structure make sense? Is it a best practice? If not what is and if that question is outside the realm of the site could someone point me to it?


title: Learn a NoSQL or become a badass with traditional RDMS - Where is/will the work be?

text: New Question Version: I've got the opportunity to spend 3 months getting good at something, its going to be either a NoSQL technology like Cassandra or optimising relational database systems. I slightly prefer trying the 'flavour of the month' cassandra but would also love to improve my relational database skills which would be very practical. This isn't about which is better, its about my employment prospects and where I am going to get work. I know there is going to be more work in relational databases, but are we going to see a bump in the level of jobs wanting/requiring NoSQL experience? Thanks guys, I'm really impressed with the amount of advice people have given so far. Old version: I'm half way through my MSc and am thinking about my dissertation which I get 3 months to work on full time. Im very comfortable with the traditional Relational Database, the question is should I work on a project where I get a good understanding of something like Cassandra, or should I really push my RDMS knowledge to the limit. Getting great at something like MySQL is a solid safe option, will there really be much work for me with Cassandra in my tool belt? I would love to do either.... Thanks for your opinions and advice.


title: Should there be a "data hygiene" index for software - to indicate how clean the program is? not leaving temp files, etc

text: Should there be a "data hygiene" index for software - to indicate how clean the program is? not creating unused temp files, registry entries, environment variables, etc. For example, look in your users folder in Windows, you'll see all manner of work space files used by your applications. For example, this makes it hard to know what needs to be backed up and what can be discarded as being machine-generated.


title: When to start thinking about scalability?

text: I'm having a funny but also terrible problem. I'm about to launch a new (iPhone) app. It's a turn-based multiplayer game running on my own custom backend. But I'm afraid to launch. For some reason, I think it might become something big and that its popularity will kill my poor lonely single server + MySQL database. On one hand I'm thinking that if it's growing, I'd better be prepared and have a scalable infrastructure already in place. On the other hand I just feel like getting it out into the world and see what happens. I often read stuff like "premature optimization is the root of all evil" or people saying that you should just build your killer game now, with the tools at hand, and worry about other stuff like scalability later. I'd love to hear some opinions on this from experts or people with experience with this. Thanks!


title: SSO between multiple Flex applications

text: We have three applications developed in **Flex** and all these use BlazeDS. These applications have their own authentication implementations **(Database)**. Also they will be deployed in **tomcat**. Deploying all these applications in the same tomcat instance is acceptable for us. We want to bring the authentication credentials of all these applications into a single place and also provide **SSO feature between these applications**. We also want the authentication module to be **configurable**. Something like the system administrator can decide if the authentication should be done against **a database or LDAP**. Say, if the user successfully logs into app1, and when he access app2 in the same browser he should be automatically logged in. Same goes for logout as well. We have been exploring **OpenAM, jGuard and JOSSO**. I'm not sure if these require lot of customization to work with **Flex**. I would like to know how people are implementing SSO for Flex applications. **Is there a common and simple SSO solution available for Flex based applications ?**


title: reading parameters and files on browser, looking how to execute on server

text: I have a site done in Rails, which uses javascript to load files and generate forms for the user to input certain information. Those files and parameters are then to be used in a fortran code on the server. When the UI was on the server (using Qt), I would create a parameters file and execute the fortran code using threads so I wouldn't block the computer. Now that is web-based, I need to make the server and browser talk. What's the procedure for that? where should I start looking? I'm already using rails + javascript. I need that extra tool to do the talking, and no idea where to start.


title: Can an internally developed fast evolving, agile, short sprint web application lend itself to offshoring?

text: I have recently been set a target to achieve readiness to successfully manage and deliver results through the usage of offshore teams on our mainline development project within 12 months. Our mainline is a multi-thousand user highly available web application, and various related SAAS components delivered through the above mentioned web application. We work agile on the mainline with a rapid 1 week sprint using continuous integration. Our delivery platform is a bespoke php framework, although we have some .net services and components in the mix. My view is: an offshore team could work if we either ship out an entire isolated project for offshore development, or we specify a component for our system in huge detail up front. But we don't currently work like that, and it will conflict with the in-house method, and unless the off-shore is working within our team, with our development/deployment chain it could be an integration nightmare. So my question is, given we have a closed source bespoke framework (Private IP) which we train our developers to use, and we work agile minimising documentation, maximising communication and responding to rapidly changing requirements, and much of the quality control is via team skills building and peer review, how can I make off-shoring work on our main line development?


title: Employer purchased a Macbook for me, as a programmer what do I need to do to get my environment setup?

text: I come from growing up on dos/windows and the more I got into programming and development the more I invested time/effort into linux distributions. I had a choice between an IBM and a Macbook. I went with the Macbook to get some experience but I am not really sure where to start? I find myself wanting to install virtualbox and boot up linux. Any advice for a new Mac user who wants to get back up to speed with programming efficiently?


title: Any tools/suggestions on how to refute code coverage quality argument

text: Now I know people could consider this question duplicate or asked many times, in which case I would appreciate a link to relevant questions with answer to my question. I have been recently in disagreement with some folks about code coverage. I have a group of people who want our team to drop looking at code coverage altogether based on the argument that 100% coverage does not mean good quality tests and thus good quality code. I have been able to push back by selling the argument that Code Coverage tells me what has not been tested for sure and help us focus on those areas. (The above has been discussed in a similar fashion in other SO questions like this one - http://stackoverflow.com/questions/695811/pitfalls-of-code- coverage) The argument from these folks is - then team would react by quickly creating low quality tests and thus waste time while adding no significant quality. While I understand their point of view, I am searching for a way to make a more robust case for code coverage by introducing **more robust tools/frameworks that take care of more coverage criteria** `(Functional, Statement,Decision, Branch, Condition, State, LCSAJ, path, jump path, entry/exit, Loop, Parameter Value etc)`. What I am looking for is **suggestion for a combination of such code coverage tools and practices/processes to go with them** which can help me counter such arguments while feeling comfortable about my recommendation. I would also welcome any accompanying comments/suggestions based on your experience/knowledge on how to counter such an argument, because while subjective, code coverage has helped my team be more conscious of code quality and value of testing. * * * Edit: To reduce any confusion about my understanding of weakness of typical code coverage, I want to point out that **I am not referring to** `Statement Coverage`(or lines of code executed) tools(there are plenty). In fact here is a good article on everything that is wrong with it: http://www.bullseye.com/statementCoverage.html I was looking for more than just statement or line coverage, going more into multiple coverage criteria and levels. See: http://en.wikipedia.org/wiki/Code_coverage#Coverage_criteria The idea is that if a tool can tell us our coverage based on multiple criteria then that becomes a reasonable automated assessment of test quality. I by no means am trying to say that line coverage is a good assessment. In fact that's the premise of my question. * * * Edit:   Ok, maybe I projected it a bit too dramatically, but you get the point. The problem is about setting processes/policies in general across all teams in a homogeneous/consistent fashion. And the fear is general that how do you ensure quality of tests, how do you allocate guaranteed time without having any measure to it. Thus I like having a measurable feature that when backed up with appropriate processes and the right tools would allow us to improve code quality while knowing that time is not being force spent in wasteful processes. * * * **EDIT: So far what I have from the answers:**   * Code reviews should cover tests to ensure quality of tests   * Test First strategy helps avoid tests that are written after the fact to simply increase coverage %   * Exploring alternative tools that cover test criteria other than simply Statement/Line   * Analysis of covered code/number of bugs found would help appreciate the importance of coverage and make a better case   * Most importantly trust the Team's input to do the right thing and fight for their beliefs   * Blocks Covered/# of tests - Debatable but holds some value Thanks for the awesome answers so far. I really appreciate them. This thread is better than hours of brainstorm with the powers that be.


title: What is the role of traditional issue tracker when Scrum / Kanban board is used?

text: From a very high level view, to me it seems there are generally 2 types of Project Management tools:   1. **Traditional issue trackers** like Fogbugz, JIRA, BugZilla, Trac, Redmine etc.   2. **Virtual card boards** / agile project management tools like Pivotal Tracker, GreenHopper, AgileZen, Trello etc. Sure, they overlap in one way or another, e.g. Pivotal Tracker tasks can be imported to JIRA, GreenHopper itself is implemented on top of JIRA issue base etc. but I think one can still see the difference in orientation between those two types of tools. Traditional issue tracker seems to be used even in companies otherwise doing agile project management. My question is, why do they do that? I also feel that we should use an issue tracker in my company but when I'm thinking about it, I'm not actually sure why should we need it. For example, Trello development seems to be managed by using Trello itself (see this virtual wall) even though they have access to Fogbugz, one of the best issue trackers around. So maybe we don't need traditional issue tracker when we'll be doing 100% of our work in an agile manner using one of the agile PM tools?


title: Design for a plugin based application

text: I am working on application, details of which I cannot discuss here. We have core framework and the rest is designed as plug in. In the core framework we have a domain object. This domain object is updated by the plugins. I have defined an interface in which I have function as `DomainObject doProcessing(DomainObject object)` My intention here is I pass the domain object, the plug in will update it and return it. This updated object is then passed again to different plugin to be updated. I am not sure if this is a good approach. I don't like passing the DomainObject to plugin. Is there a better way I can achieve this? Should I just request data from plugin and update the domain object myself?


title: Should I write a wrapper within a manager object?

text: I have three classes that work together to do one function (from the perspective of the rest of my program). There is a little bit of set up between them, so, to make it easier for the rest of my program, I grouped them into:   * `ListManager`: object, which initializes them to the right values when it is constructed. The three objects it stores are:      * `Timer`:     * `TriggerManager`: basically a wrapper around an `ArrayList` that manages `Trigger` objects     * `CueList`: a linked list with the usual getters and setters that come with that.  Since the rest of my program is only interacting/referencing the `TriggerManager` class, should I write wrapper methods for the objects it manages?   1. So should I make `ListManager.add(Cue c)` as a wrapper for `CueList.add(Cue c)`.    2. OR should I just add getters for the three objects and let the rest of my program use that to manipulate them. I tend to think that the later option is far more maintainable, but at the same time, the code produced if I make the wrapper just seems... prettier... What's the best practice in situations like this?


Assuming:   * The employee and company are parting on good terms   * The new company is OK with a little contract work as long as it doesn't distract from the new job   * The former company wants the help and the employee is willing to work a few hours a week Is it a good idea to do contract work for a former full time employer? Has anyone ever done this? How did it work out for you? I can see some possible pitfalls, so I wonder how good an idea it really is. What difficulties do you encounter doing development work outside the office and on a different schedule from the rest of the programming staff and how can they be overcome? If I do go forward, what would be a fair amount to request as compared to current salary?


title: Are there any notable examples of business disasters directly attrutible to open-source software?

text: In "enterprise" environments, I've observed a strong prejudice towards proprietary software. Even in large business that use Java, it is unusual to find MySQL or PostgreSQL, and WebSphere and WebLogic are strongly preferred over JBoss or Tomcat. This is very understandable. While many developers prefer Tomcat or Postgres to WebSphere or Oracle DB, they are not the ones that make the final decisions in these matters. Whoever does make the decision regarding which DBs and application servers will be used in production will find that the licence fees seem quite small compared to being fired for choosing the free software that caused something really, really, bad to happen. I'm not asking the question of whether Postgres is as good as Oracle. That's not the point. Oracle doesn't get chosen over Postgres after a careful considerations of features and benchmarks. Postgres doesn't enter the conversation, because free software isn't trusted in certain places. I'm curious if this lack of trust came about in response to any specific events. So my question is this: **Are there any documented cases of business calamities (failures, significant loss of revenue, significant loss of corporate data, etc.) that were shown to be the result of deficiencies in open-source software?** _Clarification:_ If you have experience with enterprise level companies that fully embrace OSS, that have to prejudice in the matter but make choices based on the needs of the particular situation, then **Good for you!** Your experience doesn't change the fact that other enterprise companies have a very different attitude, and my question is valid even if these companies are in the minority.


title: Workflow: Using binary document formats in Git without locks (moving from subversion)

text: We're a software consultancy with a multitude of projects for different customers. We traditionally use Subversion, but are currently considering moving to Git. A significant portion of the documents we produce are shared with our customers (requirements, global designs, test specs, etc), and we use MS Office to produce these. In Subversion, we could use its "Lock" feature to ensure that no one was editing the same document at the same time. In Git, you can't do that since by its distributed nature, git doesn't have locks. Locks are really little more than a communication mechanism, but they're a very effective one. Currently, our code and customer-facing documents are typically in different subfolders of a different svn repository. When moving to git, what would you recommend we do? I see a set of options:   1. We move the svn repositories to git 1-on-1. Instead of using locks on the Office files, we do what the git people suggest and somehow try to change our workflow to fix it. This could be working in a branch on any document edit, and merging that over review. This approach breaks over e.g. Excel sheets that contain project management info; they're easily edited by team members (and we encourage that this is done), but not subject to any formal review process   2. We use git for code and svn for docs and project management. This has the disadvantage that certain more design-ish documents won't be "nearby" the code it specs, increasing the chance that people forget to update them. Additionally, everybody has to use and understand two sets of tools. That said, maybe this is a great opportunity to move to text-based doc tools (latex, markdown, HTML, whatever) for non-customer-facing design docs.   3. Like 1, but we hack up a `git lock` command that does what svn lock does for us (toggle the read-only flag appropriately and sync with a server through some means). I don't buy the argument that locks don't work in a DVCS because the system should even work when you're entirely offline. Svn locks can be overridden as well; they're a _communication_ mechanism. Without some sort of network connection, you won't get your computer to communicate a lot. We can't be the only shop who're very happy with how `svn lock` fits in our workflow, right? Any ideas or tips? I found http://stackoverflow.com/questions/119444/locking-binary-files-using- git-version-control-system but the discussion is rather technical; i'm looking for ways to solve or avoid the practical problem of two team members editing the same binary file at the same time.


title: Reveal detailed license-errors?

text: So after one has programmed and integrated a licensing solution into his or her application, how should one deal with licensing errors? My understanding is: Show whether a license is valid or invalid - and report if the license server is not reachable. Nothing more, nothing less. Licenses could be invalid due to a variety of reasons: Invalid Machine-Code, maximum number of activations reached, invalid licensed version... But should we report them to the user or just tell him "okay", "not okay" or "license server not reachable"? I don't know if this is the right place to ask, maybe security.stackexchange.com is more suitable, but that could be true for ux.stackexchange.com, too... So I'm asking it here.


title: Can I migrate a clone of Google Code repository into Github?

text: I want to create a clone of a Google Code repository, which I cannot download due to Country restrictions and I want to migrate that clone into Github, which I can use without any problem. The thing is I have a Github account and I can browse through GoogleCode but I cannot take my TortoiseHg and clone a repo just like that because I'm from Cuba and I get a lovely Google page saying that I cannot go into Google code. I'm guessing you know how I manage to browse :) I would like to import a mercurial repository into my Github repo, my questions:   * **Is it possible?**   * **How can I do it?**


title: Wrapping basic functions in high-level functional-programming languages

text: I'd like to know if there's a general guide or best practice for wrapping basic functions. Let's take J for example. It has several 1-or-2 character "functions" called primitives. Examples:   * `,` : Flatten a matrix or append to a vector   * `{` : Catalogue combinations or take nth item of a matrix   * `{.` : Take first or n elements of a matrix   * `}` : Amend items in a matrix Some J programmers think it best to use them as such, other will wrap them in functions like so:   * `Append =: ,`   * `TakeFirst =: {.` I found that's not always practical because I'm used to the actual "symbols", but that basically means I'm biased. So, any advice on the best practice to use? To wrap or not to wrap?


title: Which is better: to include HTML inside PHP code or outside it?

text:
Look at this:               <?php     echo "Hello World";     ?>
     <?php     echo "Welcome";     ?>      And now look at this:               <?php     echo "Hello World";     echo "
";     echo "Welcome";     ?>      Which one of the above examples is considered to better (at least from performance point of view)?. I know the examples are trivial but I want to follow good practice habits from the beginning so when I have more and more lines they would not affect the performance or whatever in a negative way.


title: How to find a project that uses specific frameworks/technologies?

text: I would like to practice specific technologies/frameworks like Hibernate, Spring, GWT and so on. How can I find an open-source project that uses specific frameworks technologies so I can contribute to it?


title: Why was the percent sign (%) chosen as the format specifier for the printf family of functions?

text: Everyone knows that, at least in C, you use the `printf` family of functions to print a formatted string. And these functions use a percent sign (`%`) to indicate the beginning of a format specifier. For example, `%d` means to print an `int`, and `%u` means to print an `unsigned int`. If you're unfamiliar with how the `printf` function and format placeholders work, or simply need a refresher, the Wikipedia article is a good place to start. **My question is, is there a particularly compelling reason why this was originally or should be chosen in the future as the format specifier?** Obviously the decision was made a long time ago (very likely for a predecessor of even the C language), and it's been more or less "standard" ever since then (not only in C, but also in a vast array of other languages that have adopted its syntax to varying degrees), so it's far too late to ever change. But I'm still curious if anyone has any insight on why this choice might have been made in the first place, and whether it still makes sense as the choice if one is designing a new language with similar functionality. For example, with C# (and the other family of .NET languages), Microsoft made a slightly different decision regarding the operation of the string formatting functions. Although some degree of type safety can be enforced there (unlike with the implementation of `printf` in C), and therefore it is unnecessary to include an indication of the type of the corresponding parameter, they decided to use zero-indexed pairs of curly braces (`{}`) as format specifiers, like so:               string output = String.Format("In {0}, the temperature is {1} degrees Celsius.",                                   "Texas", 37);     Console.WriteLine(output);          // Output:     //     In Texas, the temperature is 37 degrees Celsius.      The documentation for the `String.Format` method contains more information, as does this article on composite formatting in general, but the exact details are rather unimportant. The point is simply that they abandoned the long- standing practice of using `%` to indicate the beginning of a format specifier. The C language could just have easily used `{d}` and `{u}`, but it didn't. Anyone have any thoughts on why, whether this decision makes sense in retrospect, and whether new implementations should follow it? Obviously there's no character that could be chosen that wouldn't have to be escapable so that it could be included in the string itself, but that problem is quite well solved already by just using _two_ of them. What other considerations are relevant?


title: Limitations of Polymorphism in statically typed languages

text: I program mostly in statically typed languages, like C++ and Java. A common strategy employed in languages like these to handle dealing with collections of objects which are _related_ , but which need to employ specific behaviors, is to use polymorphism and inheritance hierarchies. But Polymorphism only works when the Base class has a method (virtual function) which can then be overridden by every Derived class. But there are often cases where a Derived class needs to have a method, and it doesn't make sense to place a method of the same name in the Base class, because it is very specific to the Derived class. Let me give a concrete example that many of us can probably relate to: the HTML DOM. Javascript programmers are quite used to doing things like iterating over collections of DOM nodes. They take for granted the dynamically-typed nature of Javascript when they do something like:               node = document.getElementById("foo");     for (var i = 0; i < node.childNodes.length; ++i)          doSomething(node.childNodes[i]);      Something like this would be very messy to do in a statically typed language like Java, because inheritance-based polymorphism doesn't lend itself well to situations where Derived classes have methods which don't exist in the Base class. For example, when iterating over the above HTML Nodes, we might find a DIV node, which has certain methods, and a Text node, which has certain different methods, and a TABLE node, which has its own unique methods - and it wouldn't make much sense for ALL of these various methods to exist in a common Base class "Node", because they are highly specific to each Derived type. (e.g. a DIV node has no need of a "cells" method, but a TABLE node does.) So, in a statically typed language, you'd be forced to fall back on something like Type Enums and a lot of messy down-casting to check what type of Node you have. So basically you end up with messy code like:               Node node = document.getElementById("foo");     for (int i = 0; i < node.childNodes().length(); ++i)      {        Node n = node.childNodes().elementAt(i);        if (n.type() == Node.DIV_NODE) doSomethingWithDiv(((DivNode)(n)));        else if (n.type() == Node.TABLE_NODE) doSomethingWithTable(((TableNode)(n)));        /* etc... */     }      This is similar to what C programmers do, and it's seemingly the sort of thing virtual functions were designed to _avoid_. And yet, when you're faced with a situation where there are various different methods in a Derived class for which it doesn't make any sense to place in a common base class, you have no recourse but to resort to something like Type Enums. So, how is this problem usually addressed in statically-typed languages? Is there a better design pattern than Type Enums?


title: Javascript, JQuery and now AngularJS What is happening?

text: I have been away from computers for about 3 years and starting to get back into programming. Lots has changed in resources and help sites available on the web especially the evolving StackExchange community. I come from the IRC #javascript, #html, #php days with php.net and a bit of google search finds here and there. With that said, before I took my break from programming JQuery was around but not nearly as common as today. I personally stay away from it finding it easier to just write what I need done in traditional javascript. Now I have just stumbled across AngularJS. I do not know much about it, just looked at the home page and saw a few script samples. My question is: Am I hindering my clients by using javascript while being ignorant to JQuery and/or AngularJS?


title: Graph/diagram editor that works with pseudographics

text: Is there a graph/diagram editing tool that can output (or even better also parse) pseudographics, that can be easily inserted into source code comments? Like this:               +---------------+                 |  Some Class   |            +---------------+     |  ----------   |----------->| Another Class |     | @its_attribute|            +---------------+     | @another_attr |           /      +---------------+  --------/             |         /             |        /     +---------------+     |Something Else |     +---------------+


title: Ship Early, Ship Never

text: This started as a "Note to Self," so please excuse me if the frustration is all too evident and the writing is less than stellar... Three major subjects I've had at the forefront of my mind lately:   1. Motivation   2. Learning (Curiosity)   3. Doing (Making) I've been studying motivation and incentives for months now. It seems there are an infinite number of different motivations that people might have for doing things (I realize that sounds trite but bear with me). I've been really drawn to it because I'm desperate to find out **why I do the things I do and why I don't do the things that I want to do but don't do**. I'm in the midst of reading Paul Graham's excellent Hackers and Painters book. In it, he makes the case that hackers and painters are very similar because they are both "makers." Painters _make_ paintings. Hackers _make_ software. Painters don't necessarily need to understand the chemical composition of paint to make beautiful paintings. And hackers don't necessarily need to know 1's and 0's to make beautiful software. Graham then draws the distinction between disparate computer science fields:   1. some people seem to be studying mathematics   2. some people seem to be studying the computers themselves   3. the hackers are _making_ software. The difference is incredibly important. It seems the motivation for some is to _make_ beautiful things. And the motivation for the others is to learn out of curiosity. Certain motivations seem obvious to me, but curiosity seems a bit less obvious. I would certainly consider myself as a curious person with a seemingly unquenchable thirst to learn just about everything I can. But this is exactly where the problem comes up. The thing that scares me so much is that I desperately want to _make_ things. I desperately want to _do_ things. I want to write a book. I want to paint a painting. I want to compose a song. I want to _do_ things like travel. But the strangeness is that I also want to _learn_ things. I want to learn to play guitar. I want to _learn_ about art history. I want to _learn_ more about philosophy and literature. The key seems to be the balance between learning and doing... between studying and making. While I'm not sure how much one should learn about a given thing before doing it, I know for certain that I find myself constantly on one side rather than the other. As it stands now (and as far as I can tell I've always been this way), I am a learner and not a doer. I've read great books. I've practiced guitar for years. I've spent countless hours studying programming. But I've written 0 books. I've composed 0 songs. I've coded 0 beautiful programs. I've painted 0 beautiful paintings. I've started 0 viable businesses. The scary part of all this is that there are probably countless unfinished works of art in the world. Is this my misanthropic revenge against society and culture to never _produce_ or _finish_ any of the works of art that I start? Perhaps the worst part (aside from this being my natural inclination), is the fact that I f***ing know better. I just finished books like "Getting Things Done" and "Making Ideas Happen." I've aggregated and synthesized countless words of wisdom on how to _do_ things and how to _make_ things. Imagine the horror of going through life without being able to do the things you want to do. If this is something you've struggled with (and hopefully overcome), please share. If not... perhaps some delicious pity would make me feel better. [UPDATE: Just wanted to send a quick thanks to everyone that shared their thoughts. I deliberately left the question somewhat open-ended in hopes of encouraging discussion and having others refashion the central problem around their similar experience, and I think it worked out great... there's a lot of amazing insight here to work with and it was really helpful. Thanks again.]


title: Do startups need a dba?

text: I am a Database/ BI person with 5+ years of experience (SQL Server and Oracle). I would really love to work for a startup, but from the feeling I get from seeing the job postings, most startups are not looking for people other than developers for their IT team. Do startups even look for other IT people other than developers? And if so, how can I connect with ones that are looking for DB persons?


title: Which is more expensive multiple conditional branches or multiple relational expression in a single condition?

text: Which is more expensive in terms of processing costs               if ( x < 20 && z == "M") {         // statements 3     }          if ( x >= 20 && w && x <= 65) {         // statements 1     }           if( x >= 20 && z == "F"){         // statements 2     }      or this               if ( x < 20 ) {         if( z == 'M') // statements 3;     } else         if ( x <= 65 && w == true ) // statements 1;         if ( z == 'F' ) // statements 2;     }


title: How important is it to reduce the number of lines in code?

text: I am a Software developer who works on J2SE (core java).   Often during our code reviews we are asked to reduce the number of lines in our code. It's not about removing redundant code, it's about following a style that focuses on doing the same things with fewer lines in the code, while I believe in having clarity in code even if it means increasing the number of lines. What do you think is the right way of doing things?   If LOC (lines of code) is a small number, how does it affect the code? If LOC is a larger number, how does it affect the code? example from the website : "javaranch" -               public static void happyBirthday(int age)     {               if ((age == 16) || (age == 21) || ((age > 21) && (((age % 10) == 0) || ((age % 25) == 0))))                 {                  System.out.println("Super special party, this year!");         }         else         {             System.out.println("One year older. Again.");         }     }      VS               public static void happyBirthday(int age)     {              boolean sweet_sixteen = (age == 16);         boolean majority = (age == 21);         boolean adult = (age > 21);         boolean decade = (age % 10) == 0;         boolean quarter = (age % 25) == 0;              if (sweet_sixteen || majority || (adult && (decade || quarter)))         {             System.out.println("Super special party, this year!");         }         else         {             System.out.println("One year older. Again.");         }     }


title: Entity Framework 6 Conventions

text: I use the Entity Framework often, but I have one area of confusion I would like to understand better. If I wanted to have a navigation property in an Entity such as               public virtual ExampleObject Example {get;set;}      it is also the done thing to have an Id property               public int ExampleId {get;set;}      My undertsanding is this creates a FK, but if I omit it, the functionality is the same and the FK seems to be created anyway. So, is there a reason for the additional field?


title: Why doesn't the .NET world have anything like rails/grails/django/roo?

text: It seems to me that rapid-development web platforms are going to radically change the world of web applications. It has been five years since Rails 1.0 was released for Ruby, and since that time we have seen Grails for Groovy, Django for Python, and Roo for Java. But to my knowledge (which is probably limited, being a Java/Groovy progammer) there is no similar framework for C#. Does such a thing exist? If not, why not? **Edit:** It's quite possible I'm not using the right words when I say "rapid- development," but I'm talking about frameworks that can conceivably allow you to build a working blog engine in 30 minutes. You couldn't reasonably do this with, say, Java, Spring, and Hibernate, given the various configuration needed to allow your controllers to be found, and both configuration and code necessary for your entities to persist and be retrieved. So I'm talking about frameworks that handle all of the CRUD with a convention- over-configuration mentality. If someone has the right words for what I'm talking about, let me know.


title: How can I get an anonymous user to submit bugs on a private GitHub project?

text: Our company has a private GitHub repository for the project I'm working on. After a full summer of work, it looks like we'll be launching this week (wheee!). However, I want to include a "submit a bug" link in the program that leads to a form somewhere where the user can fill out a form that becomes an issue for us on GitHub. Googling around hasn't found any solution (or someone who has the same problem). Is this possible (through some API, perhaps?) or will I have to manually enter the bugs my users report?


title: "A proof is a program; the formula it proves is a type for the program"

text: This might be a philosophical kind of question, but I believe that there is an objective answer to it. If you read the wikipedia article about Haskell, you can find the following: > The language is rooted in the observations of Haskell Curry and his > intellectual descendants, that "a proof is a program; the formula it proves > is a type for the program" Now, what I'm asking is: doesn't this really apply to pretty much all the programming languages? What feature (or set of features) of Haskell makes it compliant with this statement? In other words, what are the noticeable ways in which this statement affected the design of the language?


title: Can one edit a built-in Python module?

text: I'm currently learning Python and I'm at the point in the book about using the Math library. I looked on the Python website and noticed the library was a bit scarce and am writing some more useful functions. For example, I went ahead and wrote a function to take coefficients and return the roots of the equation. Essentially a quadratic formula function. I'm wondering if it's possible to add this to the python Math library. If it isn't, how do I save it such that I can use that function in other Python programs I write just by calling it?


title: Object Design & Cohesion - Issue & potential refactoring

text: **Abstract** I have been trying to get my head around the cohesiveness of some functionality in our code base. I’ve approached this design in different ways, and lately I’m convinced that I took the wrong approach, as in I incorrectly applied the Single Responsibility Principle. **Issue** The problem domain is a Well, otherwise known as a round hole in the ground. The current code looks something like this... I have a set of data in a data only object... Note: This is not the full code, just method names to keep things short...               public class WellData     {         public string Name { get; set; }         public ICollection<SurveyPoint> SurveyPoints { get; set; }         public ICollection<GeometryItem> GeometryItems { get; set; }         public ICollection<TemperaturePoint> WellTemperature { get; set; }         public ICollection<FluidPoint> WellFluids { get; set; }     }      I broke functionality that operates on this data into several small classes. As per below…               public class ReferenceWellSurvey     {        ICollection<SurveyPointCalculate> _calculatedSurveyPoints;        double GetTvdAtDepth(double depth) {}        double GetAzimuthAtDepthRad(double depth) {}        double GetInclinationAtDepthRad(double depth){}        double GetTortuosityPeriodAtDepth(double  depth ) {}        double GetTortuosityAmplitudeAtDepth(double depth ) {}     }          public class ReferenceWellGeometry     {        ICollection<GeometryItem> _geometryItems;        double GetFrictionAtDepth(double depth) {}        double GetHoleIdAtDepth(double depth) {}     }          public class ReferenceWellTemperature     {        ICollection<TemperaturePoint> _wellTemperatures;        double GetTemperatureAtDepth(double depth) {}        double GetSurfaceTemperature(double depth) {}     }     Etc.      I’ve realized lately when looking at our code that I have to glue all this back together to make it usable where I need it in the application logic. Something like….               public class ReferenceWellData     {     private IReferenceWellGeometry _refWellGeometry;     private IReferenceWellTemperature _refWellGeometry;               private IReferenceWell _refWellGeometry;               private IReferenceFluid _refWellFluid;            //Proxy functions from each class to glue it all back together…     }      A few things that led me to the current mess. The well data class contains several collections of information and if everything is in one class most functions will only operate on a small subset of the data. At the time I felt that would create low cohesion, now a few months later, I feel these things do actually all belong together. Additionally, there are several classes in my code that need to call just one method of the ReferenceWellSurvey class, GetTvdAtDepth(). Really what I did didn’t solve this issue. After thinking more about this, and after reading this Wikipedia article http://en.wikipedia.org/wiki/Cohesion_(computer_science), I’m starting to see that I have committed a few programming sins. • Anemic domain model • Low cohesion • Constructor over injection in code where I try to glue things together • Giving a class that depends on GetTvdAtDepth access to other methods that it does not need, violated Interface Segregation Principle. **Solution** I’m looking for that Goldilox design that doesn’t give too much responsibility to any one class (No God Objects), while yet maintaining a good degree of cohesion.   My current thoughts on fixing this are as follows. Move the functionality that operates on the well data into the same class. This should help get this functionality closer to Communicational/informational cohesion.               public class WellData : IWellData      {         public string Name { get; set; }         public ICollection<SurveyPoint> SurveyPoints { get; set; }         public ICollection<GeometryItem> GeometryItems { get; set; }         public ICollection<TemperaturePoint> WellTemperature { get; set; }         public ICollection<FluidPoint> WellFluids { get; set; }             // Operates on SurveyPoint collection         double GetTvdAtDepth(double depth) {}        double GetAzimuthAtDepthRad(double depth) {}        double GetInclinationAtDepthRad(double depth){}        double GetTortuosityPeriodAtDepth(double  depth ) {}        double GetTortuosityAmplitudeAtDepth(double depth ) {}        //Operates on WellGeometry collection         double GetFrictionAtDepth(double depth) {}        double GetHoleIdAtDepth(double depth) {}        //Operates on WellTemperature collection        double GetTemperatureAtDepth(double depth) {}        double GetSurfaceTemperature(double depth) {}     }      Next to address the issue of several classes needing just one function, I could make this one function into a separate interface IGetTvdAtDepth. In this way, my classes that need that functionality can depend just on this interface, which I can inherit into my WellData interface, and implement it there, but not tie my other classes to all the functionality that is in my WellData class. Thoughts on this approach vs. the original approach? One thing that bothers me about doing things way is that in my API I'm using bastard injection to fulfill the required dependencies of this class... Right now I have three required dependencies, a Survey calculator, and a special class that references data at different measured depths. I'd like to move away from this, but that seems to point back toward having services do more of the lifting...


title: How can I motivate my teammates to work?

text: I've been recruited in a small team of seven developers about 4 months ago on a small scale Java project involving a basic game development, where each programmer has to do a certain part. For example programmers 1,2 and 3 have high experience in Java and they get harder tasks, while programmers 4 and 5 handle the small details of the project. (They also program, but they get the boring stuff) We are relatively well organised, we all live in different countries and communicate by skype and share the source by Dropbox, where we keep a log of updates, a task list and whatnot, but in general a problem always occurs in the project development. Basically everyone gets motivated for a day or two and works on some fast code that does it's job (Although not always 100% efficient, but clean and maintainable) then stops working and becomes un-motivated because he thinks he's the only one doing his job. Very little work gets done and their programming knowledge could lead the project sky-high if they used it properly. There's always a de-motivating factor in project development, such as "I don't like this feature, I think we should go back" or "Nobody works so I won't either" and in the end, it all turns out messy. My question is - what could be done to motivate them? How could I manage them in a way to constantly have them working on the project? **EDIT:** I forgot to add that all the programmers on the project are doing this mostly for experience, **_they work for free_** and they do not get paid. I personally work because I wish to gain experience in working with a team.


title: How can a true Vector be implemented in Haskell?

text: How could a true Vector type be implemented in Haskell? In order for something to be a Vector, it has to be stored sequentially in memory, with `O(1)` random access. But Haskell hides its memory management, and its datatypes describe trees! So how could you express that kind of requirement?