Wisdom of using open source code in a commercial software product

I'm looking at using some open source code in my ASP.NET web app (specifically dapper). Management is not a fan, because open source is seen as a risk that has bitten us before. Apparently previous developers have had to rewrite things after having open-source components fail. The pros seem to be:   * It does a lot of stuff for me that would otherwise involve either lots of boilerplate code or Microsoft's recommended but slower solution (Entity Framework). Cons:   * It's complex enough that if it were to fail suddenly in production, I would be hard pressed to fix it. However, it's in use on a much higher-traffic site than mine, so I don't think it'll end up being a high risk portion of the project. What is the consensus here? Is it unwise to use open source code in my project that I don't know/understand as well as I do my own code?


Violating the Interface Segregation Principle?

I currently have an interface named `InternalEntityIdTransformer`, which has a `getInternalId` method, that given an external id returns the corresponding internal one. Now I am working on functionality that will need to do the opposite transformation, and go from internal id to external id. Is adding an `getExternalId` method to this `InternalEntityIdTransformer` a bad violation of the ISP? (All places that currently are using this interface only need the `getInternalId` and are not going to care about `getExternalId` at any point.) And if it is, then is is particularly harmful? Should I rather have two dedicated interfaces here? The language used is Java, PHP or C#.


Is it good idea to write variable names that match application specific terms?

Let us say I am writing a Facebook like application. I write code like below               $this->get_user_friends();       then next morning the boss says that we don't want to call Friends friends anymore, we will call them Pal. Then all the templates are changed but what about the code above? After 2 years when some programmer will have to look into it he is likely to get confused isnt it ? What do you guys really do ?


C++ Iterator lifetime and detecting invalidation

Based on what's considered idiomatic in C++11:   * should an iterator into a custom container survive the container itself being destroyed?   * should it be possible to detect when an iterator becomes invalidated?   * are the above conditional on "debug builds" in practice? **Details** : I've recently been brushing up on my C++ and learning my way around C++11. As part of that, I've been writing an idiomatic wrapper around the uriparser library. Part of this is wrapping the linked list representation of parsed path components. I'm looking for advice on what's idiomatic for containers. One thing that worries me, coming most recently from garbage-collected languages, is ensuring that random objects don't just go disappearing on users if they make a mistake regarding lifetimes. To account for this, both the `PathList` container and its iterators keep a `shared_ptr` to the actual internal state object. This ensures that as long as _anything_ pointing into that data exists, so does the data. However, looking at the STL (and _lots_ of searching), it doesn't look like C++ containers guarantee this. I have this horrible suspicion that the expectation is to just let containers be destroyed, invalidating any iterators along with it. `std::vector` certainly seems to let iterators get invalidated and still (incorrectly) function. What I want to know is: what is expected from "good"/idiomatic C++11 code? Given the shiny new smart pointers, it seems kind of strange that STL allows you to easily blow your legs off by accidentally leaking an iterator. Is using `shared_ptr` to the backing data an unnecessary inefficiency, a good idea for debugging or something expected that STL just doesn't do? (I'm hoping that grounding this to "idiomatic C++11" avoids charges of subjectivity...)


Lead Programmer definition clarification

I have been working on PHP and MySQL based web application for more than 5 years now. I started my career as an Intern, and worked my way up through Jr Developer and Software Developer to Sr. Software Engineer (Team Lead), and that's what I am nowadays. I was looking at the link at Wikipedia regarding who is a lead programmer. The link states the following: > A lead programmer is a software engineer in charge of one or more software > projects. Alternative titles include Development Lead, Technical Lead, > Senior Software Engineer, Software Design Engineer Lead (SDE Lead), Software > Manager, or Senior Applications Developer. When primarily contributing in a > high-level enterprise software design role, the title Software Architect (or > similar) is often used. All of these titles can have different meanings > depending on the context. My current job responsibilities are more or less like a _Development Lead_ and to some extent near _Software Architect_ because I usually design the core structure of new products, and manage 2-3 project simultaneously while assisting other teams regarding the structural design of their projects. I am usually on call with clients along with project managers. I code most of the time when my team is stuck somewhere, has a heavy workload, is integrating some third party API, etc. Does what I do qualify for a **Development Lead** title in accordance with my above mentioned job descriptions?


Why are floats called "real numbers" in some languages?

Some programing languages, notably Pascal, have a type of numbers called "real". However, mathematically speaking, these types aren't real. For them to be "real", these types have to be able to represent **any** real number. Real numbers like 1/3 and irrationals, however, can't be represented in floating point. So why do some programing languages call these types "real"?


C#/.Net/Programming talk

Lately we have decided in our company to have a monthly 30-60 minutes talk on a subject that relates to C#/.Net programming or anything else that will make us better in our work.   We are currently programming in C# 3.0 with .NET 3.5 in VS 2008. So... I've tried to come up with a topic for the talk (Something that is not too trivial but still could be applied as a guide for better programming, and not just an ad-hoc solution for specific problem) but nothing has come to my mind. I will be more than happy to hear about such topics that could fit my need. Feel free to elaborate or provide references to any resource that would help :)


design practice for business layer when supporting API versioning

Is there any design pattern or practice recommended for business layer when dealing with multiple API version. For example, I have something like this. http://site.com/blogs/v1/?count=10   which calls business object method GetAllBlogs(int count) to get information http://site.com/blogs/v2/?blog_count=20 which calls business object method GetAllBlogs_v2(int blogCounts) Since parameter name is changed, I created another business method for version 2. This is just one example but it could have other breaking changes for which it requires me to create another method to support both version. Is there any design pattern or best practice for business/data access layer I should follow when supporting API Versioning?


What are good words for defining multiples?

In databases you might take about one-to-many. This means there's one thing that maps to zero or more others. In this kind of style I'm looking for words that define min/max amounts of things. So far, I have:                       min     max     one      1       1     many     0    infinite     optional 0       1     ???      1    infinite      Is there a single word that fits '???' to mean more than one?   Do you have better alternatives for 'optional'? I'm wondering if there are any conventional names for those concepts?


Is 25% to me as sole author a good deal?

This is my first contract negotiation. So I've written a program which supports some hardware that the company makes. (The support is important, and most customers will buy it, but the software product is ultimately optional.) It will sell for about $2K/license and they sell 70-80 hardware systems/year. The market here is biomedical research, i.e. the customers are individual research labs in universities and hospitals. The company will be hosting the software (obviously) and it will be part of their marketing pitch. They tell me that a 75-25% split is typical. Really? How does this smell to you guys? What are numbers that you have worked with? Edit: A little more info. I have written an open-source version of this program that has been out about a year. The contract is to write a commercialized version (basically, more features) which I would give to them. They are going to pay me some money up front, then pay me 100% of gross up to a certain amount (low six figures) and after that, 75/25% them/me in perpetuity. They will have all rights and I won't be able to build another product in that category as long as I have a relationship with them.


Is there a design pattern or technique in Coldufsion/Java for serializing objects differently depending on customer's desires?

I have data available in the form of Structs and Arrays. I need some design pattern advice, which I can use to model this situation into corresponding Coldfusion Components. Here is the data definition I have objects like   * Hotel   * Apartment   * Bus Each object has it's attributes and images. Images have also different types like thumbnails, gallery etc. Attributes may be simple or complex   Simple Attributes like: name, code, id etc   And complex attributes are themselves objects which have it's own Attributes and Images. The second part is Customers. Our customers receive these objects as XML export files. Each customer has it's own requirements. For example some want one kind of attributes and other want other attributes. Some want that one type of images should be exported and some want all image types should be exported.


Continuous "Platform" Integration?

We have accumulated a large codebase of somewhat-well-document projects, many of which aren't actively being used, but that we want to be able to start using again quickly if necessary. What is the best way to automatically make sure that these projects stay in working condition as the dependencies backing different projects are upgraded? These dependencies tend to be large, open-source and external, such as OpenCV and FFMPEG. Between consecutive versions, they offer Warnings during compilation about the use of recently-deprecated functions; jump more than a few version, though, and updating becomes a significantly more challenging task.


Online medical image processing grand challenges

I'm currently working on my thesis, and I'm looking for an/some online medical image processing grand challenge(s). I already know this site but I need a challenge which has microscopic image dataset like cells, chromosomes, bacterias, viruses etc with classification or recognation objective. Like karyotyping. Maybe someone is working on this field or his university made a challenge what I'm looking for, and can help me.


Coming from QA, how can one land that first development job?

I have been in QA for 10 years, trying to get into development for about 5 of them. I have taken classes in C++, Java and C#. I was able to write some tools and unit tests in C# at my current job and (by all accounts) did a good job of it. However, 8 months ago, my employer tasked me with the responsibility of establishing the new QA group. Now I'm doing manual testing and deployment with no promise of returning to development. I have looked at the job boards and there are a lot of jobs for web developers, so what else can I do to get one? I've picked up some books on Ruby on Rails that I plan to work through on the Mac at home, but I'm not sure employers would be interested in anything but commercial web development. Do you have any suggestions on how I can use my experience to get a job as a junior developer? And I mean one that entails programming; the postings I've seen for junior developer amount to doing all the grunt work besides coding. They should just call them "Technical Secretaries".


Organizing classes with many properties that need to be iterated through

Sometimes when I'm working with a class (usually one that represents a database model), I'll have about 15 different properties on it, usually of different types. These are properties that need to be accessed by the users, as well, so each property will typically need some function like               T getPropertyName();     setPropertyName(T value);      But, it's also extremely valuable for me to be able to iterate through each property **in a particular order** (although, I suppose that "value" may stem from laziness of not having to type each one individually). Is there some logical way to set up this class, so that I could iterate through it in this order? Or am I helpless for organization, and I should just go back to the basics of having 15 private variables, and 15 "getters" and "setters"? As an aside, currently I'm working with Android and Java, so answers pertaining specifically to that would be the most helpful, but seeing how I encounter this somewhat frequently in other languages, too, any solution would be ideal. **Edit:** I've been thinking about using something similar to a Bundle with a list of keys, but I don't know how effective that would really be either.


A way to return multiple return values from a method: put method inside class representing return value. Is it a good design?

I need to return 2 values from a method. My approach is as follows:   1. create an inner class with 2 fields that will be used to keep those 2 values   2. put the method inside that class   3. instantiate the class and call the method. The only thing that will be changed in the method is that in the end it will assign those 2 values to the fields of the instance. Then I can address those values by referencing to the fields of that object. Is it a good design and why?


How Data Transfers differ on Smart Phones: Iphone vs. Android vs. Windows Phone

I am interested in how each individual smart phone is allowed to handle data transfers within a third-party app. I am interested in designing apps that allow customers to update, transfer, download, etc. data from their smart phone to their personal computer and vice-versa. (Ranging from just text, to XML, to a Relational Database) I only have experience with the Ipod Touch before and one particular app that maintained all the data on an online server, so to update the data on your pc or iphone you had to go online, are there other ways to do it? Like bluetooth, wireless LAN, USB, etc? I believe Apple has certain policies on this in order to control the App Store and individual Iphones. I suppose each company has a particular policy on how an app is allowed to transfer data to another system, does anyone have a good understanding of this? Thank you.


Newbie seeking advice on programming in general

need some of you to remember back to a time when you might have been bad at programming... Been at my new job (as a software developer) for a couple of months now, passed probation period. Have very little programming experience (C++ only) and am currently working with asp.net MVC and silverlight. So there's a website the company has been working on and I am joining the effort to make it better, iron out bugs etc. The problem is - learning about a system/website which has already been made, via visual studio. I ALWAYS feel HUGELY overwhelmed, never knowing which part of this line should I look up, and generally having lots of trouble getting the big picture. Visual studio itself is something I'm finding it difficult to get to grips with, let alone the asp.net framework. I get the impression that because my coworkers have more experience than me, they are getting all the good jobs, and I am left with crap to do - stuff which is not even vaguely programming. Meaning they are learning/creating more, and I am learning/creating near nothing. I'm getting demoralised, and too scared to say anything. I'm not stupid, I've read and practiced plenty of the fundamental programming concepts...I'm just bloody scared of this damn framework. I look at it and just feel paralyzed. The result is that I keep asking the older veteran guy of questions, and he is getting irritated, and would rather give me easy/mindless/non programming jobs to avoid wasting time with helping me out. Then when I don't understand something, I'm hesitating about whether or not I should ask him yet, and trying to decide if it would be a waste of time. I'm the kind of person who picks things up slowly, but with a lot of attention to detail. The former I think is making me look incompetent though. Anyone get where I'm coming from please say something helpful....I'm scared of losing my job in a few months or something...


Embed Python into Lua?

I've found a lot of things about embedding Lua into Python, but I was wondering is is possible to embed Python into Lua? I've searched for a while, and couldn't find anything on it, so maybe some of the StackExchange community knows. It's not a big deal if it _isn't_ possible, but if it is it could be really awesome for a Lua game I am currently working on, using LÖVE. Thanks! :)


Technology/Programming mailing lists How do you manage?

Email Alerts, Blog /Forum updates, discussion subscriptions general programming/technology update emails that we often subscribe to.Do you actually read them ? or go direct to the source when you find time. Often we might the mail of programmers filled with loads of unread subscription mail from technology they previously were following or worked on or things they wish to follow .Some or a majority of these mail just keep on piling up . I personally have few updates that i wish i read but constantly avoid and keep of for latter and finally delete them in effort keep the in box clean. Few questions come to mind regarding this   * Do you keep such mail in separate accounts?    * Do you read all the mail you have subscribed to?   * Do you ever unsubscribe to any such email if you aren't reading them?   * How much do you really value these email.    * Lastly do you keep your in box clean ? wish to deal with this in a better way.


Static and dynamic programming languages

Someone who's just getting started in programming asked me about the advantage of different approaches programming languages take. For example, some allow the programmer to omit variable declarations and just use them (like PHP). Others require declaration but not necessarily with a type. And others require a full declaration of the variable (including its type). So what's the advantage of each approach? Why is it better to (not) declare a variable and/or its type? The ones that don't require a type I believe allow for more efficiency for the programmer. You can just take a variable and use it rather than think about what type it may have at the moment of needing it. And potentially you can change its type later on. But is there more to it than that?


Dropping database in Grails is too easy. How to prevent accidental drops?

I just dropped production database. It happened because I used dbCreate = "create" instead of "update" in DataSource.groovy. I was changing some domain models and wanted to update the database. dbCreate value was empty string (""), and I accidentally changed it to "create" instead of "update". How could I prevent this from happening in the future (grails wise or in general)?


Compile-time IOC

Has anyone started a project to do IOC at compile time (possibly using Roslyn or Linq MethodInfo emit)? My experience with IOC containers has thus far been great, baring a few small issues   1. Many IOC containers are slow to start up, as much of the resolution logic occurs here   2. It is often hard to ensure that resolution is possible, as compilation no longer ensures that the constructor can be called   3. Often IOC containers add a small overhead to the runtime (some aren't even small, often the ones that start up quickly run slowly) It seems to me that the ideal solution would be to add a compile step to the build chain that adds a Factory class instead of IOC. Has anyone done this before? If not, why not?


What's the point of passing a parameter by reference in C#?

> **Possible Duplicate:**   >  Why are objects passed by reference? Doesn't C# send the objects themselves? So unless it's some kind of swap function for primitive typed variables - why would I send an object by reference?


What was the worst experience you've had with a customer/user?

As a programmer, you have to interact with your users/customers in some way to both develop and support the software they pay for. > What was the worst experience you've gotten from those interactions? What did you learn from that experience? Why did this situation happen? How can you to avoid it in the future? I'm also interested in best experiences you have, and why they were different from the worst. and how you can reproduce them.


Best practices for logging and tracing in .NET

I've been reading a lot about tracing and logging, trying to find some golden rule for best practices in the matter, but there isn't any. People say that good programmers produce good tracing, but put it that way and it has to come from experience. I've also read similar questions in here and through the internet and they are not really the same thing I am asking or do not have a satisfying answer, maybe because the questions lack some detail. So, folks say that tracing should sort of replicate the experience of debugging the application in cases where you can't attach a debugger. It should provide enough context so that you can see which path is taken at each control point in the application. Going deeper, you can even distinguish between tracing and event logging, in that "event logging is different from tracing in that it captures major states rather than detailed flow of control". Now, say I want to do my tracing and logging using only the standard .NET classes, those in the `System.Diagnostics` namespace. I figured that the TraceSource class is better for the job than the static Trace class, because I want to differentiate among the trace levels and using the TraceSource class I can pass in a parameter informing the event type, while using the Trace class I must use `Trace.WriteLineIf` and then verify things like `SourceSwitch.TraceInformation` and `SourceSwitch.TraceErrors`, and it doesn't even have properties like `TraceVerbose` or `TraceStart`. With all that in mind, would you consider a good practice to do as follows:   * Trace a "Start" event when begining a method, which should represent a single logical operation or a pipeline, along with a string representation of the parameter values passed in to the method.   * Trace an "Information" event when inserting an item into the database.   * Trace an "Information" event when taking one path or another in an important if/else statement.   * Trace a "Critical" or "Error" in a catch block depending on weather this is a recoverable error.   * Trace a "Stop" event when finishing the execution of the method. And also, please clarify when best to trace Verbose and Warning event types. If you have examples of code with nice trace/logging and are willing to share, that would be excelent. **Note:** I've found some good information here, but still not what I am looking for: http://msdn.microsoft.com/en-us/magazine/ff714589.aspx Thanks in advance!


My father is a doctor. He is insisting on writing a database to store non-critical patient information, with no programming background

So, my father is currently in the process of "hacking" together a database using FileMaker Pro, a GUI based databasing tool for his small (4 doctor) practice. The database will be used to help ease the burden on reporting from medical machines, streamlining quite a clumsy process. He's got no programming background, and seems to be doing everything in his power to not learn things correctly. He's got duplicate data types, no database-enforced relationships (foreign/primary key constraints) and a dozen other issues. He's doing it all by hand via GUI tool using Youtube videos. My issue is, that whilst I want him to succeed 100%, I don't think it's appropriate for him to be handling these types of decisions. How do I convince him that without some sort of education in these topics, a hacked together solution is a bad idea? He's can be quite stubborn and I think he sees these types of jobs as "childs play" How should I approach this? Is it even that bad an idea - or am I correct in thinking he should hire a proper DBA/developer to handle this so that it doesn't become a maintenance nightmare? NB: I am a developer consultant of 4 years and I've seen my share of painful customer implementations.


One to Many Relationship Django

let say I want my User model to have only one location and my Post model to have many location. How Do I design the model? This is what I have in mind so far. Is this going to work? Do I need to create two different Location model for each User and Post model? `class User(models.Model):` `class Post(models.Model):`               class Location(models.Model):      user = models.ForeignKey(User,unique=true)      post = models.ForeignKey(Post)


Hallway usability testing and quiet working environment together

How can one achieve both the 8th and 12th point, i.e. > Do programmers have quiet working conditions? and > Do you do hallway usability testing? mentioned in The Joel Test: 12 Steps to Better Code?


Why is VB so popular?

To me, Visual Basic seems clumsy, ugly, error-prone, and difficult to read. I'll let others explain why. While VB.net has clearly been a huge leap forward for the language in terms of features, I still don't understand why anyone would choose to code in VB over, say, C#. However, I still see (what seems to be) the vast majority of commercial web apps from "MS shops" are built in VB. I could stand corrected on this, but VB still seems more popular than it deserves. Can anyone help answer any (or all) of these questions:   * Am I missing something with VB? Is it easier to learn, or "friendlier" than C#? Are there features I don't know about?   * Why is VB/VB.net so frequently used today, especially in web projects?


How do you handle specific networking exceptions in Haskell?

I have the following to try and connect to a server:               testAddress :: HostName -> Int -> IO (Maybe Handle)     testAddress host iPort = do         let port = PortNumber $ fromIntegral iPort         putStrLn $ "Testing - Host: " ++ host ++ ", Port: " ++ show iPort         result <- try $ connectTo host port         case result of             Left (SomeException e) -> return Nothing             Right h -> do                 putStrLn $ "Connected to " ++ host                 return $ Just h      I made the exception to catch "SomeException", but I know that's not the proper way to do it; as it will catch everything, and you can't handle individual cases. I can't find the names of specific network exceptions though. There doesn't appear to be any documentation for the Network package, and a every example I can find on google just uses "SomeException". If I try and connect to a random host and port, and I don't attempt to catch anything, I get the error: " _*_ Exception: connect: failed (Connection timed out (WSAETIMEDOUT))" But it doesn't seem to give me the exact name of the exception to try and catch. I thought it might be "WSAETIMEOUT", but when I tried catching that, I got a compilation error saying that it couldn't find the constructor for "WSAETIMEOUT". What should I do. I don't want to just catch everything and treat it the same, because then I don't know whats going on. Thank you


Object Chain through an Interface

Say I have 3+ types of objects:               function Sea() {         var logs = [Logs];         this.getLog = function(ind){return logs[ind]}     }          function Log() {         var bumps = [Bumps];         this.getBump = function(ind){return bumps[ind]}     }          function Bump() {         var frogs = [Frogs];         this.getFrog = function(ind){return frogs[ind]}     }          function Frog() {         this.ribbit = function(){alert("Onomatopoeia!")}     }      So, `Frog` doesn't know about `Bump`, and `Bump` doesn't know about `Log`, but `Log` can access `Bump` and `Frog` directly and indirectly, respectively. Now, let's say that whenever a `Frog` utters a `ribbit`, the `Log` moves slightly (although `Frog` internally doesn't care what happens outside of itself). Now, Mrs. Demeter suggests that I don't do this:               Sea.getLog(5).getBump(2).getFrog(1).ribbit()      It reads nice, but there's some problems. Besides the issue of tight coupling, this method also makes it impossible for the `ribbit` to move the `Log` unless `Frog` ends up getting a reference about `Log`, which means the coupling gets even tighter. However the alternative "one dot" method looks a tad atrocious:               Sea.tellFrogOnBumpOnLogToRibbit(1, 2, 5)      * * * A reasonable solution that has been suggested here (I think) is to create a concise but tightly coupled interface to... interface, with the more business- logicy code:               function SeaInterface() {              var sea = createSea(); //Genesis 1:10              var logInterfaces = [LogInterfaces];         this.getLog = function(ind) {return logInterfaces[ind]}          }          function LogInterface() {              var log = createLog();              var bumpInterfaces = [BumpInterfaces];         this.getBump = function(ind) {return bumpInterfaces[ind]}              //Private method that Frogs will know about internally:         var move = function(){}      }          function BumpInterface() {              var bump = createBump();              var frogInterfaces = [FrogInterfaces];         this.getFrog = function(ind) {return frogInterfaces[ind]}          }          function FrogInterface(log) {              var frog = createFrog();              this.ribbit = function() {             frog.ribbit();             log.move(); //I'm allowed to do this because I'm a simple interface         }          }      That way, I could still use chaining and make the code read well (note: chaining is not a necessity):               Sea.getLog(5).getBump(2).getFrog(1).ribbit()      And the `Log` would still move after a `ribbit`. In the end, it's really just an attempt to minimize the detrimental affects that objects knowing about other objects can cause. Questions:   1. Is there an equally readable or more readable and fool-proof way to achieve the same thing (multiple objects within objects where occasionally manipulating an inner object affects an outer object)?   2. Besides requiring more code, and the fact that the interface itself is tightly coupled (acceptable?), what other problems might arise if I were to interface with the actual object through something like this? Also... does this method have a name? I haven't really seen many approaches like this in the wild, which is what makes me nervous.


Android SDK and Iphone SDK limitations

I have an idea that would require triggering a call or text message simply by pressing or dialing a certain number. Example: Pressing 2324 on the pin code. Despite it not being your pin code to unlock the device, my application (always running in the back) would detect your code "2324" has been typed in and send a call or text message. Another Example: Holding volume button for 5 seconds and then pressing "2" on pin code lock. This could be another trigger. My question is, how flexible are the iOS and Android SDK's to allow this level of customization? Can I override tone settings via an application (change from Silent to Normal)? Can I close applications? What can't I do? I tried researching this but have not come up with any recent or updated answer. Hoping someone could clarify what I can't/can do with Iphone and Android SDK's.


A Web application as a REST API client: how to handle resource identifiers

Several concepts related to REST conflict in my head when I try implementing it. I have a REST-ful back-end API system that holds the business logic, and a web application that provides the UI. From various resources about REST (particularly, REST in Practice: Hypermedia and Systems Architecture) I know that I should not expose raw identifiers of my entities, but rather return hyperlinks with `rel="self"`. Consider the example. The REST api has a resource that returns a person:               <Person>       <Links>         <Link rel="self" href="http://my.rest.api/api/person/1234"/>       </Links>       <Pets>         <Link rel="pet" href="http://my.rest.api/api/pet/678"/>       </Pets>     </Person>      The problem arises with the web application. Let's assume it returns a page that contains a hyperlink to browsers:               <body class="person">       <p>         <a href="http://my.web.app/pet/???????" />       </p>     </body>      What should I put into the `href` attribute? How do I keep the API entity URL in the web application to be able to get the entity when a user opens the target page? The requirements seem conflicting:   1. The hyperlink `href` should lead to the web application because it is the system hosting the UI   2. The `href` should have some id of the entity because the web app must be able to address the entity when the target page opens   3. The web app should not parse/construct REST URLs beacuse it's not REST-ful, The mentioned book says > URIs should be opaque to consumers. Only the issuer of the URI knows how to > interpret it and map it to a resource. So, I cannot just take `1234` from the API response URL because as a RESTful client I should treat it as if it was something like `http://my.rest.api/api/AGRIDd~ryPQZ^$RjEL0j`. On the other hand, I must give some URL that leads to my web app and is enough for the app to somehow restore the API's original URL and use that URL to access the API resources. The simplest way is probably just using the API URLs of resources as their string identifiers. But web page urls like `http://my.web.app/person/http%3A%2F%2Fmy.rest.api%2Fapi%2Fperson%2F1234` are ugly. It all seems quite easy for a desktop app or a single-page javascript app. Since they live continuously, they can just keep the URLs in memory together with the service objects for the application lifetime and use them when necessary. With a web app I can imagine several approaches, but all seem weird:   1. Replace the host in the API URLs and keep the result only. The huge downside is that it requires the web application to handle whatever URL the API generates, meaning monstrous coupling. Moreover, it's not RESTful again, because my web app starts interpreting the URLs.   2. Expose the raw ids in the REST API together with the links, use them to build Web App's URLs, and then use the ids on the web app server to find the required resources in the API. This is better, but will affect the web app server performance because the web app will have to go through the REST service navigation issuing a chain of get-by-id requests of some form to handle any request from a browser. For a somewhat nested resource this might be costly.   3. Store all `self` URLs returned by the api in a persistent (DB?) mapping on the web app server. Generate some ids for them, use the ids to build the web app page URLs and to get the URLs of the REST service resources. I.e. I keep the `http://my.rest.api/pet/678` URL somewhere with a new key, say `3`, and generate the web page URL as `http://my.web.app/pet/3`. This looks like a HTTP Cache implementation of some sort. I don't know why, but it seems weird to me. Or Does it all mean that RESTful APIs cannot serve as backends for web applications?


Strategy to use two different measurement systems in software

I have an application that needs to accept and output values in both US Custom Units and Metric system. Right now the conversion and input and output is a mess. You can only enter in US system, but you can choose the output to be US or Metric, and the code to do the conversions is everywhere. So I want to organize this and put together some simple rules. So I came up with this: **Rules**   * user can enter values in either US or Metric, and User Interface will take care of marking this properly   * All units internally will be stored as US, since the majority of the system already has most of the data stored like that and depends on this. It shouldn't matter I suppose as long as you don't mix unit.   * All output will be in US or Metric, depending on user selection/choice/preference. In theory this sounds great and seems like a solution. However, one little problem I came across is this: There is some data stored in code or in the database that _already_ returns data like this: `4 x 13/16" screws`, which means "four times screws". I need the to be in either US or Metric. Where exactly do I put the conversion code for doing the conversion for this unit? The above already mixing presentation and data, but the data for the field I need to populate is that whole string. I can certainly split it up into the number 4, the 13/16", and the " x " and the " screws", but the question remains... where do I put the conversion code? **Different Locations for Conversion Routines** 1) Right now the string is in a class where it's produced. I can put conversion code right into that class and it may be a good solution. Except then, I want to be consistent so I will be putting conversion procedures everywhere in the code at-data-source, or right after reading it from the database. The problem though is I think that my code will have to deal with two systems, all throughout the codebase after this, should I do this. 2) According to the rules, my idea was to put it in the view script, aka last change to modify it before it is shown to the user. And it may be the right thing to do, but then it strikes me it may not always be the best solution. (First, it complicates the view script a tad, second, I need to do more work on the data side to split things up more, or do extra parsing, such as in my case above). 3) Another solution is to do this somewhere in the data prep step before the view, aka somewhere in the middle, before the view, but after the data-source. This strikes me as messy and that could be the reason why my codebase is in such a mess right now. It seems that there is no best solution. What do I do? **Question** My goal is to figure out how to structure and where to place my unit conversion code within the system. Software system in question is MVC-like (Zend Framework 2 - like) LAMP system. **Specific Example** Right now I have some class that given an `id` at creation time, has a method `getValue()`, which returns `4 x 13/16" screws`. Depending on `id`, different numbers can be produced, but they are still in inches. I should note that some numbers are written with the dividing bar (`13/16"`) and some use decimal notation (`0.8125"`). How could I set up my framework so that I can display such values in millimeters as well?


When to use mixins in Ruby

I am wondering when to use mixins? I have read about them. Many authors compare them to interfaces, abstract classes, etc. Mixins are modules that are mixed-in and modules are a way to group similar methods, constants and classes together. I have seen examples where a module for math functions is created. It makes sense to group and reuse such functions but should I only mix these in a class if I am faced with an inheritance situation? Should I mix these in anytime I want to use them in a class? Should they be used exactly like interfaces in other languages or are there other subtleties?


Would comments increase the chance of being fired?

I have had this burning question for a while. If I have a job and I comment my code well, to the point that anybody can now understand my hard work, would it make me less indispensable to the company? From my experience any homework assignment I hand in that is fully commented receives lower grades than, for example, a friend who submits fairly similar code without comments. Almost as if the comments helped nitpick the assignment. I have observed this several times in different classes. I have seen this even in my own tests. One question I commented the code and it was nitpicked until I lost 2 points. Then another question I was unsure and I didn’t comment, I earned full points on it and when I tested the code at home it not only failed to compile but it wouldn’t solve the problem. In the other hand I like comments, it helps me code, but now that I have a job I feel like submitting my code without comments. Any advice on the matter? * * * Since it was mentioned that I might be writing comments that don't contribute positively; here is a sample of something I just coded:               // Deactivate all enemies.     foreach(Transform t in transform)        t.SendMessage("Deactivate");      In this case I do think my comment is helpful, since it won't be clear that `Transform` is actually an `Enemy`, it could be anything really.


Is thinking out loud during an interview really the best strategy?

In another question I asked recently about best practices for whiteboarding, there was general consensus that thinking out loud while coming up with the answer was the best strategy. Indeed, long moments of silence are awkward. However after recent interviews I have noticed that if my thinking out loud leads to wrong solutions or down the wrong path, that with further consideration I would have seen, interviewers tend to quickly jump in and point out problems with my approach, especially if I stop to pause for a minute. This was not an isolated case, and happened during more than one interview with more than one interviewer. The other thing is that after the interview, on a problem I absolutely bombed, when I sat down and sketched out the problem on a piece of paper in silence I was able to sketch out the solution pretty quickly. Thinking out loud ends up with me spending brain cycles on reflecting on how what I say must be registering with the interviewer and in addition there's a fear of recognizing that I've gone down the wrong path and starting over after having written something on the board wastes a lot of time. Once you've started down one path and realize you've written a lot of junk, you can't undo it, whereas if you've thought quietly about it the interviewer wouldn't have seen the mess and it would have been quicker since whiteboarding a bad idea takes up more time than simply considering a bad idea. I don't want moments of silence but at the same time speaking takes more time, leads to self-consciousness and can lead to interviewer intervention on something I might have figured out myself with just a little more time.


What norms/API for monitoring my servers?

I have a dozen server applications installed on my customers intranets (they can send http requests over the internet but cannot be called from outside). They're written in various technologies, mainly java and Go. I want them to regularly push information about their state towards a central server which is visible on internet. Some of this information is generic ( _is it ON ?_ ), some is specific (size of a cache in an application for example). The main goal is to be able to make a small web page on which I could instantly check the state of every servers. And maybe later add some kind of notification in case of problem. Obviously I can do this by writing a few dozen lines of code each side (or a little more if I put this data in a database) but in order to ease future evolution, it could be interesting to use some existing norms or libraries. So, what are the current opensource free and light solutions to do this, preferably with no central configuration when I add a server ? I'd prefer a norm over a library.


Would "Efficient C++" book be irrelevant now due to compiler improvements?

I am planning on purchasing this book to learn more about C++ programming with regards to fast code. However, the book was published in 1999 and I am worried most of it may be irrelevant now due to optimizations that compilers perform. Could anyone please advise? http://www.amazon.com/Efficient-C-Performance-Programming- Techniques/dp/0201379503/ref=cm_cr_pr_product_top edit: Found this book too, albeit also rather old: http://www.amazon.com/Optimizing-C-Steve-Heller/dp/0139774300


Checking "instanceof" rather than value using a switch statement

Is there some syntax (other than a series of if statements) that allows for the use of a switch statement in Java to check if an object is an instanceof a class? I.e., something like this:               switch (object) {          case instanceof SecondObject:             break;          case instanceof ThirdObject:             break;     }      Sidenote: I recognize that as a design pattern, checking against instanceof and making decisions based on it is not as preferable as using inheritance. To give some context why this would be useful to me, here's my situation: I'm working on a project that involves a kryonet client/server. For communication over KryoNet, you pass objects that it serializes using kryo. Anything added to the object increases the size of these packets,1 so to minimize the network traffic, you keep these objects as light weight as possible. When you receive a packet, you need to know what to do with it, so I'm making this determination based on what type of packet object the passed object is an instanceof. This approach is the same undertaken in the examples included with Kryonet's distribution. I'd love to clean up the hideous class that translates these packets into action, and figure a switch statement would at least make it look moderately more organized. * * * 1As I wrote the statement above, I had doubts about whether what I was saying was accurate. The answer below seems to disagree: > Methods don't add anything to the runtime size of an object. The method code > is not transmitted, and nothing about the methods requires any > representation in an object's state. This is not a sound reason for > instanceof testing, etc. I guess the real issue is I don't know what happens under the hood for Kryo to serialize an object and I was nervous to do anything that increased the bandwidth. Your answers have inspired me to do it with inheritance and add the appropriate methods to the objects. So thank you!


Is this a proper use of the word "enumerate"?

I'm reading a book that has a section about processes. In it is this sentence: > The next method to enumerate processes is the `GetProcessById` method. This > method does exactly what its name implies: it will take a process ID and > return information about it if it's found. This doesn't sound right to me. Google dictionary has this as a definition > Enumerate - Mention (a number of things) one by one - for ex. "there is not > space to enumerate all his works". I think of enumerate as exactly that, "mentioning", but in the context of walking through a list. If you are getting something by ID, that doesn't sound like "enumerating", that sounds like "retrieving". Am I wrong? Should I broaden my sense of "enumerate"?


How do tablespaces differ in DB2 from databases in MySQL or MS SQL Server?

In DB2, it seems there is a strong separation between what a _database_ is and what a _tablespace_ is. Where as in MySQL and MS SQL Server _tablespace_ and _database_ seemed to be used synonymously. What are the differences, if any?


How is the speed of a page affected?

I am trying to develop a single-page web application. I was wondering how big the disadvantages of using jQuery are. I have been told that it makes the application slower, but, as I have seen here, there are only 150ms at every 500 consecutive selections, which seems to me impossible to notice by a user. Others say, that with every jQuery selection, the browser will save jQuery objects in its cache, instead of DOM elements, making the cache bigger, resulting a bigger memory consumption and therefore making the application run slower. Is this true? (I have no idea how the browser's cache is working.) Is jQuery really slowing down such an application? (By this, I mean if the user will ever notice the use of this framework or not.)


Is it allowed to distribute a program which source code is under Ms-PL to paying customers?

What I want to do is bundle XML Notepad (as is, no modifications) with the installation of our commercial product. Instead of telling the customer "go to http://www.microsoft.com/en-us/download/details.aspx?id=7973 and download XML Notepad". Any one who can offer insight on how to derive the legality of this from the license?


Does MSDN follow documentation conventions for .NET, and if so is it publicly available?

While browsing the MSDN documentation for the .NET Framework Class Library (FCL) I've always been amazed by how **consistent** and fully documented it is. It's a constant companion when developing .NET applications. Most doubts that arise when using the APIs are covered. The contrast with e.g. the older Win32 documentation is striking. Some examples:   * Documentation for properties always starts out with either _"Gets"_ or _"Gets or sets"_ to specify accessors.   * Type parameters start out with: _"The type of ..."_. Does Microsoft use a documentation convention which is followed for the FCL? If so, is this convention publicly available for me to use as well?


Advice on approaching a significant rearrangement/refactoring?

I'm working on an application (hobby project, solo programmer, small-medium size), and I have recently redesigned a significant part of it. The program already works in it's current state, but I decided to reimplement things to improve the OO design. I'm about to implement this new design by refactoring a big part of the application. Thing is I'm not sure where to start. Obviously, by the nature of a rearrangement, the moment you change one part of the program several other parts (at least temporarily) break. So it's a little 'scary' to rearrange something in a piece of software that already works. I'm asking for advice or some general guidelines: how should I approach a significant refactoring? When you approach rearranging large parts of your application, where do you start? Note that I'm interested only in re-arranging the high-level structure of the app. I have no intention of rewriting local algorithms.


How to update display during large processing job

I have an ASP.NET C# application that needs to go off and iterate through a directory of .xml files and do some processing on the data inside them. This is easy enough, but i need to display the result after each .xml is processed, how can this be done? What im really asking here is how do you process a lot of data in a loop that needs to be displayed back to the client even though the server processing has not fully completed. Is this even possible? I could start the big process in a seperate thread and start a js timeout to postback and essentially poll the process but this doesn't sound great and would probably require using static variables to maintain state. Would it be correct to use SessionState / ViewState / QueryString to persist the status of which file ive processed and do away with the loop altogether? Therefore seperate the large job into seperate requests?


How do you maintain a common library used by different clients?

I am part of a software deveopment team. Originally there were just 2 of us, and two applications. To ease our job we create a set of libraries, handling stuff like GUI, database access, calculation, business rules etc, so that we can reuse them in our applications without implementing them twice. Now the team grew, 6 people and ~5 applications (and growing). The applications use the same library, which are great because we don't have to develop and maintain the same thing more than once. I and the other initial guy developed and are mostly responsible for the library, but other people have access to the code and occasionally update it to fix bugs and add improvements. But soon we notice that the more we grow and the more people can modify the code, there is a risk that "improvements"/"bug fixes" that someone does can unintentionally break someone else's application which depends on the old behavior. On the other hand, assigning one guy to maintain the libraries and make sure modifications won't break anything is not practical because there are many applications, and possibly many improvement requests to be done, and he can't be sure of everything either. How do teams normally manage situation like this? Perhaps by implementing rules on allowed modification? Defining behaviours that shouldn't be changed? There are a lot of libraries in the internet used by a lot of people, for example open-source/free to use libraries like Apache, Castle, etc. How do they make sure that changes won't break existing client codes?


Is there a formula to figure out the total execution time of sequential asyncronous processes?

I have a set of steps that need to run sequentially over a list of data. However each step only operates on a single piece of data at a time. Because of this, I can run the steps asynchronously. For example I have two pieces of data, and two steps. When step one is done processing the first piece of data, it passes it to step two. Now step one processes the second piece of data while step two is processing the first piece of data. So forth and so on until all of the data has been processed by each step. In contrast, looping through the list of items and executing every sequentially in order turns into the equation:               total_time = (step1 + step2 + ... + stepN) * number_of_items      Given that I know the execution time of each step for a single piece of data, and I know the number of items to be processed, **is there a formula that will tell me the total execution time for processing all the data items asynchronously?** I have written a program (see below) that simulates this process. I'm not entirely sure that it is computing it correctly, but I believe it is close. This was my attempt at figuring out how to solve the problem. I'm including it here to show my understanding of the problem, which may be wrong.               using System;     using System.Collections.Generic;     using System.Linq;     using System.Text;     using System.IO;          namespace ConsoleApplication1 {         class Step : Queue<object> {             public Step(int totalExecutionTime)             {                 _totalExecutionTime = totalExecutionTime;                 CurrentExecutionTime = _totalExecutionTime;             }             readonly int _totalExecutionTime;             public Queue<object> NextStep { private get; set; }             public int CurrentExecutionTime { get; private set; }             public void RunTick()             {                 if (Count == 0)                     return;                 if (CurrentExecutionTime == 0)                     CurrentExecutionTime = _totalExecutionTime;                 CurrentExecutionTime--;                 if (CurrentExecutionTime == 0 && NextStep != null)                     NextStep.Enqueue(Dequeue());             }         }         class Program {             static void Main(string[] args)             {                 int totalItems = 10;                 int[] stepLengths = new int[] { 1,2,5,2,2 };                 if (File.Exists("output.txt"))                     File.Delete("output.txt");                 WriteLine("ASYNC: {0}", TotalTime(totalItems, stepLengths));                 WriteLine("SEQUENTIAL: {0}", stepLengths.Sum() * totalItems);                 Console.WriteLine("DONE");                 Console.ReadLine();             }                  static int TotalTime2(int totalItems, int[] stepLengths)             {                 throw new NotImplementedException();             }                  private static int TotalTime(int totalItems, int[] stepLengths)             {                 var steps = new List<Step>();                 Step prevStep = null;                 foreach(var stepLength in stepLengths) {                     var step = new Step(stepLength);                     steps.Add(step);                     if (prevStep != null)                         prevStep.NextStep = step;                     prevStep = step;                 }                 var first = steps.First();                 for(int i = 0; i < totalItems; i++) {                     first.Enqueue(new object());                 }                 var last = steps.Last();                 var revSteps = steps.Reverse<Step>().ToList();                 var totalTime = 0;                 do                 {                     Display(steps, totalTime);                     revSteps.ForEach(s => s.RunTick());                     totalTime++;                 } while (last.Count < totalItems);                 if (last.CurrentExecutionTime > 0)                 {                     do                     {                         Display(steps, totalTime);                         revSteps.ForEach(s => s.RunTick());                         totalTime++;                     } while (last.CurrentExecutionTime > 0);                 }                 Display(steps, totalTime);                 return totalTime;             }                  static void Display(List<Step> steps, int totalTime)             {                 Write("[");                 steps.ForEach(s => Write("{0},", s.CurrentExecutionTime.ToString().PadLeft(2)));                 WriteLine("]");                 Write("[");                 steps.ForEach(s => Write("{0},", s.Count.ToString().PadLeft(2)));                 WriteLine("] {0}", totalTime.ToString().PadLeft(5));                 WriteLine();             }             static void Write(string fmt, params object[] args)             {                 Console.Write(fmt, args);                 using (var w = new StreamWriter("output.txt", true))                 {                     w.Write(fmt, args);                 }             }                  static void WriteLine(string fmt, params object[] args)             {                 Console.WriteLine(fmt, args);                 using (var w = new StreamWriter("output.txt", true))                 {                     w.WriteLine(fmt, args);                 }             }                  static void WriteLine()             {                 Console.WriteLine();                 using (var w = new StreamWriter("output.txt", true))                 {                     w.WriteLine();                 }             }         }     }


Python - defining exit method before importing

This breaks nothing (in my experience), but lots of things "don't break anything" and are still wrong.               #! /usr/bin/env python     """Short description of this module."""          def preferred_exit_method(*args):         #code for exiting as desired          try:         import foo         import bar         import eggs     except ImportError as e:         #code code code         preferred_exit_method(e)      So, clearly defining the program's behavior on exit, then using it during the `import` process can't be too terrible, right? But it goes against the oft- cited PEP 8, which states that modules should be absolutely be imported before anything global. It seems like an unrisky proposition, but then there's always something like this:               #! /usr/bin/env python     """Description of module"""          def exit_of_choice(*args):         #code code code         sys.exit(0)          try:         import sys         import other_things     except ImportError as e:         exit_of_choice(e)      Apart from writing code that never needs to do this because it is perfect and never fails at anything, is there a reason besides PEP 8 and "other Python people will be cross with you" not to do this? (well, I'm less concerned with the latter - even though `sys` wouldn't typically fail to import, I still sort of hate that on principle)


Which is more effective in coding? Reducing line of code and execution of code?

I have this doubt many years. I am wring some code to achieve some functionality. For example I am writing 20 lines of code to achieve the functionality and my co worker writing the code for the same functionality with just 5 lines. Since he used some looping statement to achieve that, but that code will execute around 30 to 50 times. So which is best way of coding? As per my knowledge I always try to reduce coding length as much I can.


To load or not to load data for unit tests from external files

When unit testing I often find myself debating how much of the data I feed to, and expect back from my units under test, I should include in the actual test files. The tradeoff I constantly struggling with is:   * If a large portion of the test (in code volume) consists of input and output data, it seems difficult to actually read the test, but I can easily see the actual in-and outputs.   * If I load the test data from files, I can easily test a bunch of variations on possible data input, easily reuse test data for multiple tests, but I have to leave the source code to look at another file to see what exactly the inputs are. Is either one of these an anti-pattern?


Building a regex builder

I am a beginner in programming in general and web development in particular. I am especially bad at regular expressions. Recently I was involved in building a couple of cPanel plugins(Perl-CGI) and that's when I realized how bad I am in regex. As a result, I have decided to build an online regex builder - this will help me to learn regex and help other struggling with regex. I have checked out GSkinner, Rubular and a couple of others like regexpal. It seemed to be a little difficult to use, hence i thought of writing another one. I do not know which tool is best suited for the job. should I write it in Perl or Python? My skill level is between beginner and intermediate in both those languages. What would be a good starting point - building it for the CLI or for the browser? I plan to get a string as an input, ask if the user want to search or search and replace, enter the search string (and the replace string where applicable) and then generate a regex. Would this be the right way to go?


AOP concepts explained for the dummy

I'm learning Aspect Oriented Programming and have isues understanding concepts. I'm not a bad programmer but my english is bad and can't understand fully the definitions. Can someone explain AOP concepts for dummies: join point, pointcut, weaving etc. For example: **Aspect: a modularization of a concern that cuts across multiple classes.** What that means? Thank you!


What scripting languages can be embedded within HTML?

Most of scripting languages (like Pythong, Perl, etc) generates the whole HTMLfile. However, PHP code can be embedded within html codes. PHP will process only code between `<?php ?>` tags and ignore other lines. What other scripting languages are available with possibility to be embedded within HTML?


C++ Library API Design

I'm looking for a good resource for learning about good API design for C++ libraries, looking at shared objects/dlls etc. There are many resources on writing nice APIs, nice classes, templates and so on at source level, but barely anything about putting things together in shared libs and executables. Books like Large-Scale C++ Software Design by John Lakos are interesting but massively outdated. What I'm looking for is advice i.e. on handling templates. With templates in my API I often end up with library code in my executable (or other library) so if I fix a bug in there I can't simply roll out the new library but have to recompile and redistribute all clients of that code. (and yes, I know some solutions like trying to instantiate at least the most common versions inside the library etc.) I'm also looking for other caveats and things to mind for keeping binary compatibility while working on C++ libraries. Is there a good website or book on such things?


How do I break down and plan a personal programming project?

I've just started a programming job where I'm applying my 'How to code' knowledge to what I'm being taught of 'How to Program' (They are different!). As part of this, I've been taught how to capture requirements from clients before starting a new project. But... **How do I do this for a nebulous personal project?** I say nebulous, as I often find halfway through programming something, I want to expand what my program will do, or alter the result. Eventually, I'm tangled in code and have to restart. This can be frustrating and off-putting. Conversely, when given a fixed task and fixed requirements, it's much easier to dig in and get it done. At work I might be told "Today/This week you need to add XYZ to program 1" That is easy to do. At home (for fun) I want to make, say, a program that creates arbitrary lists. It's a very generic task. How do I start with that? I don't _need_ it to do anything, but I want it to do something. So how do I plan a personal programming project? ### Related: What to plan before starting development on a project?


Variable naming conventions?

I've just started using ReSharper (for C#) and I kind of like its code smells finder, it shows me some things about my writing that I meant to fix a long time ago (mainly variable naming conventions). It caused me to reconsider some of my naming conventions for methods and instance variables. ReSharper suggests that instance variable be lower camel case and begin with an underscore. For a while I meant to make all my local variables lower camel case but is the underscore necessary? Do you find it comfortable? I don't like this convention but I also haven't tried it yet, what is you opinion of it? The second thing it prompted me to re-evaluate is my naming conventions for GUI event handlers. I usually use the VS standard of ControlName_Action and my controls usually use hungarian notation (as a suffix, to help clarify in code what is visible to the user and what isn't when dealing with similarly named variable) so I end up with OK_btn_Click(), what is your opinion of that? Should I succumb to the ReSharper convention or there are other equally valid options?


What's the best setup for a development machine (when you have multiple clients)?

I have my development machine (a laptop, since I do often go onsite to a client) setup like this:   1. Windows 7 x64 - it's a great OS, and the 64 bit version let's me put in a lot of RAM   2. 8 GB RAM   3. VMWare - I used to use Virtual PC, but VM Ware has so many features that I prefer, like support for USB etc. I develop primarily in .NET and I setup the development environment like this:   1. Very little (if any at all) developer tools on the host. Mostly I just have Office, Photoshop, etc. things that are independent from actual development   2. I have a different VM for every client. This allows me to configure the VM to their evironment, and in fact I have several clients where my VM is actually joined to their domain. Every client's VM runs _on its own external drive_! Putting a VM on it's own drive makes your VM run much faster. I use laptop hard drives in small drive cases, very easy to put in my laptop bag, and each drive has a sticker with the client's name so I can easily grab the right external drive. I usually allocate about 3.5 - 4 GB of RAM to each VM.   3. On the VM I have all the tools I need to work for that particular client, including VPN software, developer tools (SQL Server, VS), etc.   4. I have a few VM's that are "client agnostic", and these run server software (Wink2k, Win2k3, Win2k8) with IIS etc. for testing deployment, etc.   5. I have GoToMyPC set up so I can access the laptop from a remote location in extreme emergencies. In the past I have been set up differently, with the development environment set up on a beefy server running everything, and I just RDP in, so the laptop doesn't have to be that robust (it's basically just painting the screen), and I can access from anywhere. There are pluses and minuses to this, mostly that sometimes I like to develop when I am not able to connect to the internet, and my development is hindered anytime my internet connection speed is slow or lagging. How do you set up your development machine? Feel free to take this in any direction you want. . . **Note:** The only thing I would change about this is more RAM, and for multiple hard drives in my laptop so I don't have to carry around so many external hard drives.


Is there any logical reason to auto-generate code documentation?

Automatic documentation generation can be done with a variety of tools, GhostDoc being one of the more prominent. However, by definition, everything it generates is redundant. It takes a look at names of methods, classes, etc. and outputs English that _might_ explain them more verbosely. In the best case, it does what the reader could already do in their head (examples taken from here):               /// <summary>     /// Initializes a new instance of the <see cref="Person"/> class.     /// </summary>     public Person() ...      In the worst, it can actually end up generating bizarre documentation that is actually misleading in its attempt to heuristically figure out the meaning of names:               /// <summary>     /// Riches the text selection changed.     /// </summary>     /// <param name="richTextBox">The rich text box.</param>     private void RichTextSelection_Changed(System.Windows.Controls.RichTextBox richTextBox) ...      It seems that the attitude with GhostDoc is, "it's intrinsically better to have _some kind of_ formal XML documentation", but when that documentation is 100% redundant, why? Isn't it just wasting a ton of space at best? At my workplace, we have to document everything, and almost always with GhostDoc's auto-generated docs. Do you do this, and are there any rational reasons not to simply leave code undocumented if you aren't going to actually write the documentation yourself?


How not to forget new and interesting information

The thing is that I read a lot of things over a period of time because it is interesting and I like to know it and secondly it will be helpful in my future job interviews. For example I read about data structures: association, aggregation and composition; about 2 months ago with great interest and I thought I had it all but struggled big time recalling the information at a recent job interview. How do you people handle these things? How can I make my reading meaningful without worrying about forgetting about it in the future.


How do I convince my fellow devs to WANT to add comments to source code commits?

I know that Subversion (what we're using at work) can be configured to require comments on commits, however I'm not in a position of power to simply turn this on. I know that _my_ reason for commenting my commits is because it is useful, if only as a memory-jogger, to quickly understand the reason behind the commit. However, this doesn't seem to be enough to combat the two responses I always get:   1. It takes too long and I just want to get my changes into the repo.   2. It's easy enough to just look at the diffs. I even show them the value of simply putting in a JIRA issue ID and how it automatically gets tied to the issue, but still no dice with them. Worst of all, the person who _can_ make the call is in the same camp: doesn't want to bother and is fine with looking at diffs. I know it's the right thing to do, but how can I make them see the light? Even if I can't convince my fellow devs, how can I convince management that it's the right thing to do for the business?


Auto update for application hosted on multiple servers on cloud

I'm working on an application which will run on multiple Amazon EC2 instances. I wish to incorporate auto update feature for my application. The updater should update all the Ec2 instances. Also, there is a central server which governs the creation/termination of EC2 instances as per load. The central server creates a EC2 new instance from a pre-configured custom AMI (custom image which has our application pre-installed). Also, once there is an update, the pre-configured AMI needs to be updated too else it would create new instances which are not updated. Should the central server notify all the ec2 instances for an update and then the instances update themselves?Or should the application on Ec2 instance have a check for periodically updating themselves? Also how should the Amazon custom AMI be updated? Should a new instance be created from it, updated and then a new AMI be re-created and then new images be created from this AMI? What is the best way to incorporate an auto update feature for this architecture? The central server is written in Java and the application running on the cloud is written in C++. Is there a good framework available that can be used for this architecture? Please let me know on what I could be missing in the design and how it would help me to have a nice, extensible and fail safe auto update architecture. Thanks


Is listing developer's full names in splash screen or about box still a widely spread and desirable practice?

Just like in the closing credits of movies, some software vendors list the **full names of the team** that worked on the piece of software you are using. They are usually displayed in the **splash screen** (Photoshop) ![Adobe Photoshop Vintage Splash Screen](http://i.stack.imgur.com/qq1U8.png) ... or in the about box (Traktor). ![Traktor Famous DJ Software About Box](http://i.stack.imgur.com/ICNPI.png) In the demoscene, it is a mandatory practice, like in the movie industry. > How do you see that in your own software? Is there any reason why not doing > it? Is there any reason encouraging companies to do it?


When is cloud database right for me?

Some say that DBaaS (database as a service) -- aka cloud database -- is not suitable for Business Intelligence (BI), analytics (OLAP) or archiving. Is this true? More generally, when DBaaS is the most effective technical choice?


Efficient "Object with weights" structure

I need to find an "efficient" data structure / set of algorithms to do the following things: I have a list of objects. I need to assign them weights and later on increase or decrease these weights. For instance: We have the hashmaps `{o1}, {o2}, {o3}`. The `{o}`'s don't have any particullar structure, just random json. I am looking for a way of saying: Increase the weight of o1 by 1. Increase the weight of o2 by 1. Increase the weight of o1 by 1. Now give me the results sorted by their weight. I am using Python. So far I have tried using a normal hashmap to store them, but the problem is that I can't just hash the `{o}`'s. I thought of hashing the pointer of the `{o}`'s in memory, but it seems I don't have access to it in Python.


How to create business layer objects out of input parameters properly?

**Application description** I have an application of the following structure, simplified:                   Http request              ↓      +-----------------+     |  RequestParser |     +-----------------+              ↓     Business layer request object      **Problem code** The request parser layer accepts the input parameters, validates them and builds the business-layer request object. The code looks like that:               public function processMyRequest()     {         validationForm =             Form::create()                 .addIntegerValidator('order_id')                 .addStringValidator('external_id')         ;              if (validationForm.hasErrors()) {             throw new Exception();         }              return             BusinessRulessObject::create()                 .setOrderId(validationForm.getParameter('order_id'))                 .setExternalId(validationForm.getParameter('external_id'))         ;     }      **Some prerequisites** The form can be huge, so does the business layer object. Unfortunately, the Form class belongs to framework and it is final, so I can not inherit the concrete form from the base one where I could specify all the validators. The agreed solutions was to create this forms via Factory classes (this is not the Factory template though as it is not needed here: no mocks in tests, no polymorphism in client code). The RequestParser class can handle several requests. **Better version** So now the code looks like this:               public function processMyRequest()     {         validationForm = FormFactory.createSomeForm();              if (validationForm.hasErrors()) {             throw new Exception();         }              return             BusinessRulessObject::create()                 .setOrderId(validationForm.getParameter('order_id'))                 .setExternalId(validationForm.getParameter('external_id'))         ;     }      **How can I make it better? Version 1** But how should I create my object? Should I have some factory that creates it from form? I.e.,               public function processMyRequest()     {         ...         return BusinessRulessObjectFactory::createMyConcreteObject(form);     }      **Version 2** Or should BusinessRulessObject class have some method like `createFromForm()`, i.e.               public function processMyRequest()     {         ...         return BusinessRulessObject::createMyConcreteObject(form);     }      **Version 3** Or RequestParser's method `createFromForm()` would be enough, i.e.               public function processMyRequest()     {         ...         return createMyConcreteObject(form);     }          private function createMyConcreteObject(Form validationForm)     {         return             BusinessRulessObject::create()                 .setOrderId(validationForm.getParameter('order_id'))                 .setExternalId(validationForm.getParameter('external_id'))         ;     }      **So?...** I guess I should choose between the first and the second option, but what aspects should I take into consideration when choosing the way object should be created? And, actually, what way is preferable in my case?


Is it necessary for Java programmers to learn some C/System programming?

I've read a blog(in Chinese only) in which the author had jeered at Java programmers who know little about C and system programming. The author illustrated how he had found the deep reason of a Java NIO Selector exception using his knownledge of C and Windows/Linux system API. The IOException is thrown with message "Unable to establish loopback connection" when calling java.nio.channels.Selector.open() too many times. What he had found was that for each opening of Selector, a pair of TCP connections were created in Windows and a pair of pipes were created in Linux. In another blog, he also mentioned that GNU Java compiler was a clever implementation than Sun Java. What he said seems completely new and interesting to me. But I am not sure if C/system knowledge is the only way to figure out such problems quickly. Is it really worth spending much time on learning those knowledges for Java programmers?


Creating a websocket server on Linux

I want to create a websocket server and I've found a great article here. However C# will output an exe file. I'd like to have it run on a linux box. What I want to do is to connect to the server, and when something happens on the filesystem to retrieve a message from the server (using the `FileSystemWatcher` on Windows or the `iNotify` daemon on linux) and the program will run the corresponding code. So, how can such daemon for linux (in C#) or any other way to achieve this?


Inventory Consignment Flow

Not sure whether this is the right place to ask this question, but here goes.. Currently I have requirement to add support for consignment transaction in our inventory module. I have a very limited understanding of what consignment means in inventory, i.e. > Customer get stocks/products from Seller without actually buying them, the > product just resides in the Customer's inventory and it's still owned by the > Seller. Only when the Customer actually buy the stocks then only will the > ownership of the stock is transferred. The issue is i can't imagine how the data will be presented to both the Customer and the Seller. What i know is that i would need to deduct the stock from the Seller's inventory when the Customer raise a request to get the stock through consignment, but what about the 'ownership' of the stocks/products? Does that mean i would need to create another column in my table to state that for each inventory it is owned by who? Anywhere i can get information on how i should work out an inventory module like this? Thanks.


Duplication of code (backend and javascript - knockout)

We have a new developer on our team. He seems to be a smart guy (he just came in so I cannot really judge). He started with implementing some small enhancements on the project (MVC3 web application using Javascript with jQuery and Knockout). Let's say we have two values:               A - quite complex calculation         C - constant         B = A + C      On the screen there is value B and user can change it (normal texbox). When B changes, A changes as well because C is constant. So there is linear dependency between A and B. Now, all the calculations are done in the back-end, but we need to recalculate A as user changes B (in Javascript, I would use knockout). I thought about storing old A and B and when B changes by 10 then we know that new A will be `old A + 10`. He says this is dirty, because it's duplication of code (we make use of the fact that they are dependent and according to him that should be only in one place in our app). I understand it's not ideal, but making AJAX request after every key press seems a bit too much. It's a really small thing and I would not post if we haven't had long discussion about it. How do you deal with such problems? Also I can imagine that using knockout implies lots of calculations on the client side, which very often leads to duplication of the same calculations from the back-end. Does anyone have links to some articles/thoughts on this topic?


Replacing static classes with global state to a series of POJOs, beginning to feel like an anti-pattern

I'm trying to refactor some code, and one of the major changes is to remove the (ab)use of static classes to give global state. I've tried to split up some of the 'global state' functionality with POJOs that can be passed around. But the further down the rabbit hole I go the more and more I feel like this is an Anti-Pattern. Is holding state in POJOs and then passing them around bad form? It means the outline of my methods often look like this:               public MyPojo makeReport(int myInt, String pathToInput, MyPojo myPojo){         ...         if(myPojo.whatKindOfReport()==Reports.reportTypes){             ...         }         ...         myPojo.isWritingReportToFileSuccessful(true);         ....         return myPojo;     }      Where the POJO 'state' is set from the GUI that the user interacts with. For instance with tickboxes for report types etc. But this blocks other return types, and seems overly complicated. * * * I've taken this approach because the application has several 'paths' (see `whatAmIDoing`) the user can take in running it, each of which has several stages. What options the user has depends heavily on what path they pick and then from there, the result of that choice (normally, success or failure, see `myPojo.isSomethingSuccessful(true)`). I'm trying to encode that information in a POJO rather than a Global State Class. Is this an anti-pattern? How can I get round this? * * * Edit: I think what I'm after is _something_ like Chain of Responsibility. After looking at this answer I'm not sure.


What were the "core" API packages of Java 1.0?

Reading about the Google v Oracle case, I came across these questions (apparently from the presiding Judge) > ...   >  Is it agreed that the following is true, at least as of 1996? > > The following were the core Java Application Programming Interface: > java.lang, java.util and java.io. > > Does the Java programming language refer to or require any method, class or > package outside the above three?   >  ... source: Groklaw There are obviously lots of legal ramifications, Google and Oracle probably disagree on some points, and **I don't care**. Leave law to the lawyers. However, I suspect there's an interesting bit of history in here. My question is (as someone who first did any Java coding around 2001 in version 1.3), in version 1.0 of Java was anything required outside of `java.lang`, `java.util`, and `java.io` to compile a valid Java program? As an example (using C# 5.0), the `await` keyword is dependent upon ~~`Task<T>`~~ `GetAwaiter()` (amongst other things). The compiler couldn't function to spec without that class. Equivalently, were there any core runtime features (like ClassLoader*) that were dependent on other packages? I'll admit I ask out of curiosity, exactly what is necessary for minimum- viable Java (the language, ignoring all the legal bits around it) is interesting. *I am assuming that ClassLoader was even a feature in Java 1.0, it's part of the spec in 7.0 and presumably many earlier versions.


What is an "abstraction layer"?

I need a very simple explanation because I'm not a professional programmer. I found the terminology "abstraction layer" reading the documentation of mysqli extension where is described the difference among mysql, mysqli and PDO extensions in PHP. The article is this, that's where I met "abstraction layer" for the first time (referred to PDO). Now, trying to elaborate my question, we could speak of PDO abstraction layer against mysqli extension in php. So, for example, why mysqli is not defined as abstraction layer? How an abstraction layer acts? (like PDO in php) I would like to understand in a general way what is an"abstraction layer", I will not do particular questions about php or mysqli and PDO extensions. So, what is an abstraction layer? And what is its difference from a common application's extension?


Putting together Data Mappers and Domain Objects inheritance

Currently, I have a system with a Data Mapper and multiple Domain Objects which inherit from the same class, let's say B and C that inherit from abstract class A. In order to retrieve data, I need to pass a parameter to the data interface (getObject('a'), getObject('b')), based on which data for class B or class C will be returned. Then, the Data Mapper uses a Factory class to create the correct object based on some parameters (coming from the data itself). Class B and class C only differ in the implementation of one method, the rest is inherited from class A. I have a few doubts on this, it seems flawed but I can't really figure out a better way of doing it. The points are:   1. Is inheritance a good way to go about the implementation of different entities that differ in concept but only very slightly?   2. Is the factory class a good way to return the correct Domain Object?   3. Consuming the data mapper with a parameter feels wrong, is there a better way to do this? Would the use of abstraction be any better? I hope I have explained it clearly enough, if not I'd be happy to clarify.


What does it mean that "language A is written in language B"?

I often hear the term that language A is written in language B. For example, **PHP** has been written **C** , **C#** is written in **C++**. Can someone please explain what does that mean and if it is even correct? Does that have anything to do with the compiler of interpreter used by the language? In addition what are the factors on which the choice of the implementing language is built upon?


Why do you have to manually type variable names while debugging?

I've seen this in a lot of IDEs (even in the most popular and heavily used ones, like Visual Studio): if you want to watch a variable's value, you have to manually type its name in the Watches section of the debugger. Why can't there just be a list of all of them with checkboxes next to them ? The developer can then just check the box next to the one he wants to watch and that's it. Variables with identical names can probably be numbered in some way (for example `a`, `b`, `x(1)`, `x(2)`, `c`, etc. I've seen some exceptions to this (NetBeans or BlueJ), but there are exceptions to everything, right ? Maybe it's a stupid question, maybe not, but I've always wondered why this is so.


What is your code review and approval process, and what are its advantages/disadvantages?

Does your team rely on code reviews for approval of work? Is it simply QA that signs off your features and fixes? Do you have a lead programmer (or architect) that reviews code design and implementation? Or is it simply a Works on My Machine paradigm? What would you recommend or have seen that works well?


Bug Report System - Getting people to use it

I've built already a bug report system. It looks like this: ![enter image description here](http://i.stack.imgur.com/Hl6ZE.png) It is accessed using a secret key combination detected by the JavaScript code. Not hard. It has everything - sends the standard emails to management and testers, logs the Javascript variables and current DOM HTML. We are also improving the backend of the system to act as a full bug report system. Previously, it was only via email. The problem is, unfortunately, the bug reporters _still_ preferred email. Even when I refused to answer their queries until they sent a bug report, they would not consistently send them. I don't understand it, because, for them it should be easy, but they act like it was a big deal. (The appearance was slightly more complex before, but still, all they had to do, minimally, was type a subject and press SUBMIT). I can't ask them, because they really have no idea. The second issue, more difficult, is to create a way to manage these issues that will be suitable to us developers. I actually have been satisfied managing new issues and bugs via Gmail inbox but my co-worker would like to use a system. He gets more mail than I do and has other reasons. I am completely at a loss for what to do. My problem is solved as much as I need it to be. When I look at other bug report systems, they both look terrible and are often expensive. Moreover, if even one person reports a bug via email, it will be a disaster! We can't refuse every bug via email and then will have two bug reporting systems. Sorry to put out all these complaints here, but maybe someone has some insightful advice that hasn't already been said.


Recommend a design pattern/approach to exposing/tolerating/recovering from system errors, Exception handling (e.g.s in Java, C++, Perl, PHP)

Can you recommend a design pattern/approach to exposing/tolerating/recovering from system errors, Exception handling (Java, C++, Perl, PHP)? Some errors need to be reported. Some errors can be handled internally (by a retry or are inconsequential (can be ignored). How do you structure the code to catch them? But all errors need to be logged. What best practises are there? And for simulating them to be able to fully test components that are impacted by them? General non-programming-language specific question applicable to several modern programming languages but would welcome example illustrations of patterns, approaches and philosophies in Java, C++, PHP and Perl. (Also asked in stackoverflow: http://stackoverflow.com/questions/7432596/recommend-a-design-pattern- approach-to-exposing-tolerating-recovering-from-system but I thought it should be asked on programmers too because I think the programmers Q&A covers wider software/programming issues whereas stackoverflow is more about technical implementation IMHO).


Is it allowed to make multiple instances of a singleton class?

I am confused when I read this (regarding singleton design pattern): > How do we ensure that a class has only one instance and that the instance is > easily accessible? A global variable makes an object accessible, but it > doesn't keep you from instantiating multiple objects. So what is the use of singleton pattern if we can create multiple instances? **SOURCE:** Design Patterns - Elements Of Reusable Object Oriented Software (1995) - Gamma, Helm, Johnson, Vl


Moving from a traditional waterfall methodology to an agile one

My development team is in the process of 'going agile' and lot of people are looking at each other blankly, not really too sure what it means. All management are saying is 'start working agile' without suggesting any particular methodology so they're waiting to see if we can come up with something ourselves. Has anyone been in this situation before and how did you handle it? Any do's and don'ts? I'm one of the senior members of the team so there's an expectation to show some initiative. I know that what works for one won't necessarily work for another so I'm more interested in the approach not so much the end result because I think the result will come naturally with the right approach.


Escaping language pigeon hole

I have spend the last 5 or so years doing PHP, and I have to say it is far from my favorite language. I would like to move to a position doing something else (say Erlang) but how do I get people to look at me. It seems despite everything on my CV (including an upcoming book from O'Reilly) I keep getting pigeon holed into PHP type positions.


Is coding and unit testing violating the DRY principle

The dry principle states: > "Every piece of knowledge must have a single, unambiguous, authoritative > representation within a system." However when writing tests for code you are describing the expected behavior for the system twice (once in the code and once in the test). I know both descriptions are from a different perspective but share a great deal of the underlying idea. Any thoughts on this? In general I think both unit tests and the DRY principle are good ideas and I try to apply them as much a possible. This question is more on a philosophical level, but I wondered if anyone had also thought of this.


Is it possible to combine XPath and CSS selectors?

Just came through XPath. I got curious about this. Why is there a different way to select tags in XPath and CSS(selectors). Why cant there be a common way in both XPath and CSS?


Can a neural network provide more than "yes" or "no" answers?

Every example neural network for image recognition I've read about produces a simple "yes" or "no" answer. One exit node corresponds to "Yes, this is a human face," and one corresponds to "No, this is not a human face." I understand that this is likely for simplicity of explanation, but I'm wondering how such a neural network could be programmed to give a more specific output. For example, let's say I was classifying animals. Instead of it saying "Animal" or "Not an animal", I would want responses like "Dog", "Fish", "Bird", "Snake", etc., with one final exit node being "Not an animal/I don't recognize this". I'm sure this must be possible, but I'm having trouble understanding how. It seems like due to the training algorithm of backpropogation of error, as you train up one exit node (i.e., "This is a dog") and the weights of the neurons are changed, then the ideal state for another exit node that you previously trained (i.e., "This is a bird") will begin to deviate, and vice versa. So training the network to recognize one category would sabotage any training done for another category, thus limiting us to a simple "Yes" or "No" design. Does this make such a recognizer impossible? Or am I misunderstanding the algorithm? The only two things I can think of are that:   * Either we could train one neural network for each thing we want classified and somehow use those to construct a greater, super-network (so for example, a network for "dog", a network for "bird", etc., which we somehow add together to create the super-network for "animals"); or,   * Create some kind of ridiculously complicated training methodology which would require incredibly advanced mathematics and would somehow produce an ideal neuron-weight-state for all possible outputs (in other words, `insert math magic here`). (Side note 1: I am specifically looking at multilayer perceptrons as a kind of neural network.) (Side note 2: For the first bulleted "possible solution", having each specific neural network and iterating through them until we receive a "Yes" response is not good enough. I know this could be done fairly easily, but that is simple functional programming rather than machine learning. I want to know if it's possible to have _one_ neural network to feed the information to and receive the appropriate response.)


Direct database manipulation an anti-pattern?

Recently I learned that some teams have moved all their database manipulation to the actual database through the use of stored procedures. I thought that was pretty clever, since the database becomes a black box and any change to how the data is stored and manipulated won't affect application code. Is it accurate to conclude that manipulating the database in application code is an anti-pattern, since it unnecessarily couples application and storage code, or are there circumstances that would make decoupling sql queries from the application a disadvantage?


Software for prioritising issues / tasks in an ordered list/queue (ideally in Github)?

It seems to me that the best way to manage priority for programming tasks in a backlog is to simply put them in order. Do the top task first, second one next. If priority changes, re-order the queue. I thought this was exactly how things were supposed to work in Agile. I have yet to find an online open-source team task manager that supports custom ordering of tasks this way - although I might be out of date. Assembla definitely doesn't. Jira doesn't seem to. When we used Agilo in my previous company, it didn't seem to either. The only service I've found that implements this simple concept well is Google Tasks, but that's hardly suitable for managing software projects. I don't understand why this isn't the standard way to manage priority. My ideal way to track issues would be through Github. As far as I can tell Github Issues also doesn't support custom ordering of tasks. Does anyone know if there's any way to implement this on top of Github Issues somehow? Is there any way I can suggest it as a feature?