How  'simple' is a real KISS solution?

**I confess** : I have a problem to "Keep It Simple and Short" most of the time because trying to make it according to the books I have read, design- patterns I have heard etc. gives me such an enthusiasm -an enthusiasm coming from the sense of that I am on the right path to a probable perfection. On the other hand, yes, it puts an extra stress on me in terms of delivering the deadlines sometimes... But whenever I say to myself, "Next time keep it simple, you stupid!" I find it quiet hard to make it "simple" when that next-time comes, because it starts to feel weird... and uncomfortable after a point. Then I start to judge my understanding of 'simple'... > Does SIMPLE mean too short that it works but hard to maintain and extend? > > Does SIMPLE mean breaking many of the OOP principles? > > Does SIMPLE mean cheating? > > Does SIMPLE mean just keeping the deadlines without no dealy? etc. Actually, what is it? **Question is** : Can you write the EXACT definition of SIMPLE in terms of KISS principle? -if there is. Thanks!


What does it mean to drop support for Internet Explorer 6?

![youtube ie6](http://i.stack.imgur.com/ef2UO.png) When Facebook, Youtube, and even Microsoft themselves say that they've "dropped support for IE6", what do they really mean? Youtube still functionally works fine in IE6. If they mean that they've dropped support for visual appearance and fancy features, then their point is moot. Web developers have degraded IE6's appearance and fancy feature set since the dawn of time. So what does all this IE6 bashing from top companies mean for us web developers today? There's no big website that has dropped dropped _functionality_ support for IE6 because they're scared that they would lose the 5% or so customers that are still using it. Until the day Google itself blocks IE6 from searching, thereby lowering IE6's market share to near 0%, I don't see how this "support dropping" accomplishes anything.


Unit test storage on Android apps

I've been experimenting recently with Android applications. I've developed the convention (which I've seen used elsewhere) of placing my unit tests in a parallel source folder within an Eclipse project. This works well because the Eclipse JUnit runner can find the tests easily and the project with it's tests are nicely contained in the project. However, Android applications have a very specific structure, and I don't think that my normal unit tree design will work. Also, I don't really want my test code in the published app; it could effectively double the size on disk. How are Android unit tests usually organized?


How to include rookie developers into your project?

We're considering teaching some employees who have either zero or general hobbyist level programming experience to take workload off me. We use Python/Django which has some of the friendliest documentation around and a breeze to learn. I'm currently a one man IT department for my company and I don't have enough hours to develop everything the company needs. We are not a software company, but it helps to have in house IT to automate tasks, develop customer service features, analyze data, etc. How do you slowly integrate rookies working on your codebase? Say you have an intern - what do they do? I'm completely reluctant to let them design or develop core code as we'll be dealing with their mistakes / strange design patterns for years. As the primary developer, I'll be the one who has to work around their code. My thought was to have rookies only modify existing code, never building core features. I can offload work to them with simple tasks _after_ I build the feature itself. We'd like our employees to learn / find value in the company, and we generally have people 'move up the ranks'. Is it standard practice to teach people with general/hobbyist level programming? How does the "moving up the ranks" in a software company work for junior level programmers? When do they start working on core code? I'm trying to decide if it's going to cause more damage than help, and or if there's a way we can use their help without potentially risking core site code (isolated environments?). Thanks for your time guys!


Is there a canonical book on distributing computing in Java?

I have spent the last 2-1/2 years building a distributed application. We started testing it a couple months ago and we're moving it into production. Everything runs fairly well, but it could definitely run better. I'm looking for some books I can read which will help make sure we're not making any obvious mistakes. I searched online and didn't find anything by any authors I recognize as experts. Others were ten years old. Is there a book out there that's the de-facto standard for describing best practices, design methodologies, and other helpful information about distributed programming in Java? What about that book makes it special?


Heaps: Why is there a tradeoff between amount of space occupied (fragmentation), and speed at which operations are carried out?

Apparently, the two major judging criteria of the effectiveness of heaps are (1) how much we can minimize the amount of space it takes up and (2) how fast operations on the heap can be carried out, eg, malloc and free But I was wondering how these two criteria were related, namely, why there is a 'tradeoff' and why a faster heap makes it difficult for a _smaller_ heap in size. Also, why does a particular allocation alignment need to exist (for instance 8- or 16- byte) when then word size is clearly 4 bytes? If you allocate an int and a double, can't it just be: `allocate int at location 0` then `allocate double at location 4` (and then somehow keep track of the fact that a double-word is located at this location)? Then we would eliminate a LOT of fragmentation within the heap...


ID properties on Domain objects in DDD

In my domain I have an `Account` object. e.g.               class Account     {         public string Number;         public string SortCode;     }      Within the context of DDD, should this account object have an `ID` property? The `ID` would be a primary key, basically a database artefact.


Why is C not considered an 'object-oriented' language?

It seems that C has its own quasi-objects such as 'structs' that can be considered as objects (in the high-level way that we would normally think). And also, C files themselves are basically separate "modules", right? Then aren't modules kind of like 'objects' too? I'm confused as to why C, which seems so similar to C++, is considered a low-level "procedural" language where as C++ is high-level "object-oriented" *edit: (clarification) why and where, is the line drawn, for what an 'object' is, and isn't?


Implementing keyword "const"

A constant pointer is a pointer which points to a fixed memory location throughout.The question is how do you ensure that this behavior is ensured without using the keyword constant while declaring the pointer in a C program.


Why aren't macros included in most modern programming languages?

I know that they are implemented extremely unsafely in C/C++. Can't they be implemented in a safer way? Are the disadvantages of macros really bad enough to outweigh the massive power they provide?


how to choose a web framework and javascript library?

I've been procrastinating learning some framework for web apps w/ some library for AJAX, something like django with prototype, or turbogears with mootools, or zeta components with dojo, grok, jquery, symfony... The point is to spend some of my spare time, have "fun" and create cool stuff that hopefully is some useful. I think maybe I wouldn't like something like GWT or pyjamas because I wouldn't like to "get married" with some technology, I want to keep my freedom to add another javascript library, and so on. I didn't decide even the language yet, but I think I'd prefer python. PHP could be fine if there is some framework that is nice enough. Besides that, I don't even know where to start. I don't feel like learning a framework to then realize there is something that I cannot comfortably do, switch to another framework then find that a third framework has something really cool, etc. And the same goes for javascript libraries. So, some guidance would be really appreciated. I don't really know why are so many options available and what do they aim for, I guess some of them focus on some aspects and some on others, but I just want to make cool and nice apps that I can easily maintain, without spending too much time on coding or learning and avoiding the "trapped in the framework" feeling, when doing something is awfully complicated (or even impossible) with compared with the rest of things or doing that same thing on a different framework. I guess in the end I'll go for django and jquery since they are the most widely used options, afaik, but if I was going for the most widely used options I guess I should choose Java or PHP (I don't really like Java for my spare time, but php is not so bad), so I preferred to ask first. I think the question has to consider both, framework and library, since sometimes they are coupled. I think this is the place to ask this kind of things, sorry if not, and thank you.


Is a multi-page web app unsuitable when reliable server pushes are required?

Imagine a call center web application with a soft phone that automatically detects when a call has started or the caller has hung up. The obvious approach to receiving these messages would be some kind of server push (a.k.a. Comet). It's pretty disastrous if we miss one of those server pushes. **Must this application be written as a single-page JavaScript-heavy app, or is a more traditional multi-page app also a reliable option?** (Or is this what `iframe`s are for?) My biggest worry about using a multi-page app is losing push messages when changing pages. My biggest worry about using a single-page app is complexity.


How costly are the Python dict and set in-built types?

I have undertaken a project concerning database deduplication. I did some research and have found that the Python dict type actually is a hashmap that uses open addressing. In the deduplication module, we'll have some rules that determine whether two records are identical, with the rules essentially spelling out the attributes that uniquely identify the record (did not call it a candidate key as the DB is going to be non-relational, no-sql). Now let's say we deal with a really large dataset. Naturally, hashing is the way to go ( found that advice here). The question(s):   * does the module need to compute a hash _and_ then store it in a dict? Would that not be unnecessary, as the dict implementation is itself a hashmap?   * how costly is the conversion of a list to a set? That conversion should remove all the duplicates, but given the huge scale, is that practical?   * what is the cost incurred in checking membership in a dict/set using the "in" keyword? Hadoop MapReduce is not an option at least for now. I can't really dive into the Python sources to figure this out, as I'm strictly time limited :|


What direction should I consider the offset when searching strings in reverse?

I'm making an indexOfReverse utility function in my C++ program, and I have caught a bit of a snag. Implementing the offset and maxOffset in my indexOf was very intuitive to me.. These start from the beginning of the string (+offset), and go forth to the end of the string (or maxOffset if given). While implementing offsets for the indexOfReverse, though, I was wondering what the most logical way to do this is? Should the offset be from the beginning of the string, or end of the string? Is there an established norm for this I am missing somewhere? I tried explaining it to my duck, but he just looked at me funny. I'm leaning towards thinking of it from the beginning, because of its ease-of-use being more valuable to me than its counter- intuitiveness.. considering the offset from the end just makes things harder to think about in my head. I have looked at how it's done in a string library for C++, PHP, and Python, and what seems common in the description of each is finding the last of occurrence of a string where the offset is considered from the beginning, rather than doing true reverse-string searching... But I desire true reverse- string searching rather than last occurrence ofs. Is there a most logical way to consider this, though, so I can move on?


Continuing Education as a Part of Your Job

I work as a programmer for a mid-sized company (about 500 employees) in the medical industry. Before that I worked at a custom software development/consulting company. At both companies programmers were never officially given time to continue their education through taking classes, reading books or blogs, or doing research relevant to the job. At the software development company we were offered some money to pay for a class, but not offered any time off of work to take the class. I have been wondering, do most employers of programmers give time off of work to take a class, read a book, or do job related research? By time off of work I just mean some period of time where you can stop development; it does not have to mean leaving the office. I would be grateful to hear about everyone's experience with this.


Shipping test code as a form of sanity check

Have you ever shipped test code (JUnit, NUnit etc) with your application that could be runnable by the end-user ? Basic Idea is this : The application can be deployed in a varied environment and it is hard to gather all the possible hardware - software combination or pre-requisites for the application. It is however possible to write a test suite that assert that the application has all that it needs to perform the task at hand. Unfortunately this must be done by mocking a few components so that the test does not affect the real production environment. There are clear benefits to shipping these tests such as :   * give the customer a means to verify the system is in order.   * provide reports to help support diagnose issues.   * provide means for implementation team to assert their setup should work   * etc Natural way to do this would be to have a subset of tests that are actually packaged with the application (either as a separate project or as a part of each components of the whole). Even more natural would be to use the tools and techniques we already use for our own unit tests namely Unit test library, mocking framework etc. Have you ever done this ? How have you done it ? or why do you think this is a very bad idea ?


Do you use interface as tagging system for the code?

Do you use interface as a tagging system for the code, or you have a better way to remember which object does what? how do you keep in mind a complex system, after the use of the abstraction.


Dependency Injection: where to store dependencies used by only one method?

I am developing a project integrated with Dependency Injection (just for reference, I'm using Unity). The problem is that I have some Manager classes with several methods and in many cases I have dependencies used only in one method.               public class UserReportManager : IUserManager     {         private UserRepository  UserRepository  {get;set;}         private TeamRepository   TeamRepository   {get;set;}         private CacheRepository   CacheRepository   {get;set;}         private WorkgroupRepository   WorkgroupRepository   {get;set;}              public UserManager(UserRepository userRepository,                            TeamRepository teamRepository,                            CacheRepository cacheRepository ,                            WorkgroupRepository workgroupRepository,                            ... // Many other dependencies                            )         {             UserRepository  = userRepository;             TeamRepository = teamRepository;             CacheRepository = cacheRepository ;             WorkgroupRepository = workgroupRepository;               ... // Setting the remaining dependencies         }              public void CreateReportAboutMostActivesUsers(){             // Uses only UserRepository           }              public void CreateReportAboutUserInsideTeams(int teamID){             // Uses UserRepository and TeamRepository          }              public void CreateReportAboutUserHistory(){             // Uses UserRepository and CacheRepository          }              public void CreateReportAboutUsersInsideWorkgroup(int workgroupID){             // Uses UserRepository and WorkgroupRepository          }     }      The UserManager is instantiated in this way:               DependencyFactory.Resolve<IUserManager>();       Note: DependencyFactory is just a wrapper to simplify the access to the UnityContainer Is it OK to have classes like that in the example? Is there a better way to implement avoiding to instantiate all the unnecessary dependencies?


Was classical BASIC ever used for commercial software development, and if so, how were limitations overcome?

Many of us, including me, started their programming life with programs written on home computers, something like               10 PRINT "ENTER RADIUS"     20 INPUT R     30 PRINT "CIRCUMFERENCE="; 2 * R * PI     40 PRINT "AGAIN?"     50 INPUT A$     60 IF A$="Y" THEN GOTO 10     70 END      Of course, the line-number based BASIC was prone for creating spagetti code, also because most BASIC dialects missed structural statements like `WHILE`, doing everything but the `FOR`-loop with `IF`, `GOTO` and `GOSUB`. I'm talking about BASIC dialects before 1991, when QBASIC and Visual Basic appeared. While BASIC dialects may have promoted bad style amongst aspiring programmers, were there larger commercial projects created in such a BASIC dialect? If so, how did they manage to live with and workaround the obvious shortcomings? By "serious", I mean:   * Not a game (I know some commercial games were written in BASIC, for example, Pimania)   * Not freeware   * Not trivial, that is, reasonably large (say: at least 1500 LOC)   * Sold to several customers (not an in-house development)   * "Mission critical" is a plus


Interface design where functions need to be called in a specific sequence

The task is to configure a piece of hardware within the device, according to some input specification. This should be achieved as follows: 1) Collect the configuration information. This can happen at different times and places. For example, module A and module B can both request (at different times) some resources from my module. Those 'resources' are actually what the configuration is. 2) After it is clear that no more requests are going to be realized, a startup command, giving a summary of the requested resources, needs to be sent to the hardware. 3) Only after that, can (and must) detailed configuration of said resources be done. 4) Also, only after 2), can (and must) routing of selected resources to the declared callers be done. * * * A common cause for bugs, even for me, who wrote the thing, is mistaking this order. What naming conventions, designs or mechanisms can I employ to make the interface usable by someone who sees the code for the first time?


How to gain experience?

This is a problem that I think many people will find very common and some guidance from the expert users around here will be appreciated. **Background** Basically I'm a junior web developer in a team of 6 (all juniors too). 6 months ago our team leader and project manager left the company. Currently we are being managed by a non technical person. The new manager chose me to act as a technical leader for the rest of the team till the company hires a someone more experienced. **Problem** Although I'm a good developer my experience in providing solution to the company's needs is somewhat lacking. I mean I have no problem **implementing** solutions or adding new modules to the system as I have been working for 2 years already in PHP and MySql. The problem is when we are designing a new heavy feature or building a critical module that can't tolerate trial and error. Check this link for a design issue that I recently had to implement: http://stackoverflow.com/questions/10529459/building-a-cron-job-scheduler I can easily build all solutions that were mentioned in the post. The only problem is that I don't have enough experience to choose one of them. My ex- Team leader used to make the hard decisions and I really used to learn a lot from him. However, now he's gone and I'm left out all alone. **Solution** Now There is 2 solutions that I figured would be best for me:   1. Leave the company ASAP :D and find a better company that can provide me with good experience and increase my knowledge (Although I can't leave the company any time soon due to various reasons).   2. Find books, references or any available materials for large scale projects or pro web developers techniques. Basically anything beyond simple applications. This is the only option I have right now. **Notes:** I am not looking for resources to learn PHP, MySql, frameworks, ORMs or design patterns. I want knowledge transfer from experienced programmers.


Linking in code comments (to other unique anchors/comments)

How would you recommend creating "anchors" in code comments, so that during maintenance, developers can easily cross-reference other code comments. I realise that software should be intelligently structured and this should mitigate this requirement to some degree, but I have often found myself writing a comment where I would like future developers to take something else into account (not necessarily a direct dependency). For example, "If you change this mechanism, be sure to review XYZ". I'm thinking of hyper links, wiki-style, where each link has a unique identifier and can have a one-to-many relationship with other links. Ideally, if someone re-writes some of my code, I would like them to be automatically warned that "something else links here, and you should check it out in case you're changing this" - and I don't mean breaking something as in "something won't compile", but really just an easy-to-follow pointer (or pointers) to somewhere else in a code base that someone (or indeed your past self) felt there was a human-understandable conceptual link, concept or implementation. I would be surprised if there isn't already a standard in place for this, but searching for "comment", "link", "anchor" understandably yields a proverbial haystack.


Why is 80 characters the 'standard' limit for code width?

Why is 80 characters the "standard" limit for code width? Why 80 and not 79, 81 or 100? What is the origin of this particular value?


Is there a software development methodology that is best suited for iPhone Development?

Which project management and software development methodology is best suited for iPhone Development? Are there any documentation templates available which documents an iPhone Development project?


what counts as "experience" with a particular language?

I'm a CS student currently in the process of looking for summer internships, specifically because I want to develop apps for Android and/or iOS. When looking over requirements for various opportunities (any software development opportunities, not just those I singled out) it'll list "Experience with x, y, z....". My question: what exactly counts as experience with a particular language or technology? I feel fortunate in that I've had the opportunity to use several languages in my university studies, everything from VB down to MIPS assembly. Yet personally, with few exceptions, I wouldn't consider myself knowledgeable enough in most of the languages I've used to get dropped into a position and told to code x by y date. I may know the basics of the language, the syntax and what sets it apart but not enough to develop functional software without some guidance on where to start, what libraries to use etc. To use the specific example I'm faced with now: An internship I'm interested lists experience with C and/or C++ as a requirement. I've done some work with C, I know what you can and can't do, I own and have read K&R, understand how pointers work, etc. But I haven't actually written a substantial amount of code in C, I've written a few short programs and modified a few others but I've never written anything big enough where I actually had to manage memory allocation or come up with some abstractions to produce some desired functionality. So while I feel like I have the conceptual understanding, I haven't applied it. Does conceptual understanding count as experience? I'm always eager to learn and broaden my knowledge but I also don't want to over- promise (which seems like the opposite of what you're told to do on job applications). Thoughts? Advice?


Reusing code across several clients' projects

I've been a freelance web developer for 6 years. I have an issue that's bothering me and I'd like some advice. (Do note: I want advice from _experienced freelance developers_ , or people who have been in these situations before and can speak from experience, _not_ from people who are just guessing...) I've worked for a few years for Client A, and developed web app for them. Now I have a new client, Client B, and I'm developing a web app for them. Over the years, I've developed many general-purpose tools that I've used for Client A. Thankfully, most of them are in a separate open-source repo, and I've developed them on my own time. But, some tools are on Client A's repo and legally are the IP of Client A. They're not specific to that client's app, but are generic (like tools for handling times and date, url manipulating tools, etc.) Now, as I've started work on Client B's code, I copied all the tools and I've been using them for Client B's project. I know it's illegal since they belong to Client A, but I'm wondering how much of a big deal it is. I'm asking not for the sake of these 2 clients, who are small non-technology companies who are unlikely to care or even know, but for similar situation in the future of my consulting career. I considered asking Client A to open-source the tools, but I rather not. I'm the company's only developer, and a request like that might seem suspicious to the CEO. From the CEO's point-of-view, he has (1) little understanding of the situation and (2) something to lose and (3) nothing to gain and (4) a lot of important things to work on that are critical to the company. I'd like your advice, especially hearing what you did in such situations and whether it turned into a problem in practice.


A question about storing passwords

I'm creating a program (in C++) that will password protects its user's database (.dat) file. I'm confused on where to store the password? In the user's database file or somewhere else. I'm new to this concept. I don't know where a program should store the hashed password. I've been thinking for this from a long time. I have a question too. If a program stores hashed password in the database file (along with users data) is it possible for an attacker to modify the hash inside the file to some common hash like the hash of the text 'password' so that the password becomes 'password'? Edit: Okay! I've somewhat understood the password storing concept. This is what I've understood: > Get the password from the user > > Hash it (I will use SHA-512) > > Store the hash in the database file > > Done Probably, I didn't understand the symmetric hash concept. Please explain me in an easy way. And the question I have is... I'll better explain it with an example. Assume this is user's file's content               thisismydatabasefile      User decides to add a password. He types in the password and we hash it. The generated hash is somerandomhash. We encrypt the file with somerandomhash as the password and the hash is included in the encrypted file. So now the file content is               encryptedfilesomerandomhash      Imagine the attacker got the encrypted database file. He knows that the hash of the password is "somerandomhash". He now modifies the password hash 'somerandomhash' to something common like 'somehashthatheknows'. So what is a better way to store a password. For ease, how do programs like zip, 7z, rar etc store passwords inside a archive file?


Should I re-architect client's web app?

I've inherited a project that's accrued, layer upon layer, like a pearl over the last six years. It started out as a web page to let the client check the status of their work in production, and has become a full-fledged shopping cart system with a variety of domain-specific features, which involve visualizing custom graphics. Nothing hugely challenging, though with many elements rather particular to this client. The issue is that the code is super crufty, which is not surprising considering its heritage: it's like a giant ball of duct tape at this point, the database schema included; and it's really hard to wrap your head around the thing for this reason, and also because the developers who were in charge of it for the past six years weren't web developers and kind of made it all up as they went. Anyway, the system is successful and useful, and the client likes it, to the point that they regularly want new stuff added to it. But it's really hard to add new stuff to it because it's brittle, and I have been increasingly inclined to scrap all new development on the old codebase and rewrite the thing in Rails (it's all custom PHP at the moment.) The question is, should I? Reasons against:   * It's always way more work re-designing an application than you think it will be   * Especially when you're re-doing it in a different language and different framework   * Maintaining two code bases (for a while) will be extra work   * It might be better to incrementally rewrite, keeping it in PHP, and redesigning as we go Reasons for:   * At this point adding new features requires tearing the thing apart and trying to figure out what I broke. A redesign would pay for itself in short order, when this process became more regular and less chaotic   * The client's needs have changed substantially in the last six years, and it would be good to have them reflected from the beginning in the architecture   * Going to a popular and widely-supported and well-understood framework will give us the luxury of not reinventing the wheel for every part of the system, and allow us to use high-quality components other people have made Anyway, you get the point. I alternate between what I think the right thing to do is. I've developed a good relationship with the client and they trust me, so they'll probably do what I recommend. Does anyone who's been here before have any advice?


What is meant by dynamic code evaluation?

The following is from the preface of Jon Resig's new book : Secrets of JavaScript Ninjas > The portions of this book that cover features that are relatively un- > changing, such as code evaluation, with statements, and timers are > continually being used in interesting ways. There are now a number of active > programming languages that are built on top of, or compiled to, JavaScript: > Such as CoffeeScript or Processing.js. These languages require complex > language parsing, code evaluation, and scope manipulation in order to work > effectively. While dynamic code evaluation has been maligned due to its > complexity and potential for security issues, without it we would not have > had the CoffeeScript programming language – which has gone on to influence > the upcoming ECMAScript specification itself. > > I’m personally making use of all of these features, even today, in my work > at Khan Academy. Dynamic code evaluation in the browser is such a powerful > feature: You can build in-browser programming environments and do crazy > things like inject code into a live runtime. This can result in an extremely > compelling way to learn computer programming and provide all sorts of > capabilities that wouldn’t be possible in a traditional learning > environment. What is actually "Dynamic code Evaluation" ? What are its benefits ? Please illustrate with a nicely contrived example .


Do I have to deliver my utility and helper code to clients?

Over the years I've created a bunch of Java utility and helper libraries which I just attach to new projects. Then, when I deliver code to my clients, I send all the code **except** for the libraries themselves (not JARs but source code files). A client complained that he could not compile the project as some libraries were missing. I tried explaining him about my own libraries, but he was not satisfied. How do you handle such situations? I am still apporting changes to these libraries often and I cannot compile JARs each time I start working on some new project. How to overcome this issue - not to share private libraries (personal intellectual property) and have happy clients?


Design patterns to manage multiple windows/screens?

Supposed there is an application with multiple windows, like: Logo splashscreen Connecting... screen Login-usercontrols screen Logging in... screen etc. Is there a design pattern, which allows to effectively manage all those windows? (to hide previous windows, display a new window etc.)


Proper attribution of derived work in a GPL project

This is a continuation of me rewriting GPL project. What will be the correct way of attributing my project as being a derivative of some other GPL-licensed project? So far I came up with:               HgSharp          Original Copyright Matt Mackall <mpm@selenic.com> and contributors.          The following code is a derivative work of the code from the Mercurial project,      which is licensed GPLv2. This code therefore is also licensed under the terms      of the GNU Public License, verison 2.                                                               For information on the license of this code when distributed with and used      in conjunction with the other modules in the HgSharp project, please see      the root-level COPYING file.          Copyright 2011-2012 Anton Gogolev <anton.gogolev@hglabhq.com>


How is a 256 bin HSV histogram quantised?

I am doing some research on the ScalableColor descriptor in MPEG-7 and I came across this passage: > The descriptor extractions starts with the computation of the colour > historgam with 25 bins in the HSV colour space with the Hue (H) component > quantised to 16 bins, and Saturation (S) and Value (V) quantised to 4 bins > each. My statistics is a little rusty so could someone please explain (hopefully with an example) how the bins are quantised?


designing classes with similar goal but widely different decisional core

I am puzzled on how to model this situation. Suppose you have an algorithm operating in a loop. At every loop, a procedure `P` must take place, whose role is to modify an input data `I` into an output data `O`, such that `O = P(I)`. In reality, there are different flavors of `P`, say `P1`, `P2`, `P3` and so on. The choice of which `P` to run is user dependent, but all `P` have the same finality, produce `O` from `I`. This called well for a base class `PBase` with a method `PBase::apply`, with specific reimplementations of `P1::apply(I)`, `P2::apply(I)`, and `P3::apply(I)`. The actual `P` class gets instantiated in a factory method, and the loop stays simple. Now, I have a case of `P4` which follows the same principle, but this time needs additional data from the loop (such as the current iteration, and the average value of `O` during the previous iterations). How would you redesign for this case?


What is a good way to pick up where you left off?

My job is roughly a "9-5"ish type programming job (I'm occasionally there later when I need to finish something), and over the weekend I'm not in the office. When I get back to the office on Monday, I typically have to spend a lot of time getting myself back "into the groove" as well as figuring out where I was when I left, especially if I had to leave in the middle of something. Occasionally I will leave myself some written notes on a pad by my desk, but I find that sometimes (like today) it's insufficient. What are some creative ways that you use to remind yourself where you left off? I could use any help I could get because I really would like to reduce the lack of productivity that I suffer on Monday mornings. Thanks!


I need a term for an appeal to my manager better than "single box development"

NOTE: The information after the question turned out almost like someone who is venting. That wasn't my original intention. If someone does want to take the time to give me an answer/advice, skimming it might help. QUESTION: I'm looking for a better way to phrse "single box development". I'm trying to take a first stab at telling my boss (the co-owner of the company who sees every dollar spent as a dollar out of his pocket) that, while it got us this far (i.e. he can't see anything wrong with it yet!), the limit has been reached. BACKGROUND: I'm only programmer at a 40 person company. I started an LOB from scratch 6 months ago (WinForms/MSSQL). So far it's a smashing success. People that used to work until 10pm now head for the door at 6 and thank me on their way out (I know, yay for me). I'm battling an "if it ain't broke don't fix it" attitude from people who only see the external results. I sit close to the end users (18 of them) - if something doesn't work, they all tell. If it crashes, they don't care because they walk over (50 feet at most) to me, I press F5, they show me how to reproduce it and more often than now I go, "Oh, that's easy to fix - just didn't think of that case". Five minutes later I click "Deploy", and shout, "OK, get the new version!". ClickOnce deploy makes the line between web apps and desktop apps blur. Knowing I'm only one person, I have taken every measure to keep the use cases non-dependant on eachother. If I write code that could do "damage" if it didn't work I've tended to putting preventative measures into database triggers, thinking "this limits my worst case" - but this feels "creative" to me, and usually that's an indicator that it's not a long term solution. Now I have to add an ASP.NET solution added to my project. I've got two products on two different platforms with two different user bases, but all accessing the same data and for related business purposes. I need to:   1. Remain a one person software team.   2. Have some kind of thing with the word "cycle" in it.   3. Keep delivering features with the same pace and reliability. For reasons I'm sure everyone already knows (and doesn't need to tell me) I can't keep adding features and meeting deadlines while maintaining the relatively low defect rate I've managed to date. There's NO WAY I'm going to get the kind of monetary commitment required to start an in-house software company but I can't deny the benefits of having someone right there next to the stakeholders at all times observing how the business operates and ready to tweak things at a moments notice. So my goal is to inch towards the way the rest of the world does it, and my current step is to get at least one more machine so I can have a formal integration environment.


As a contractor, am I liable for bugs? (Do I need Liability Insurance?)

I've got a neighbor who has been trying to sell me insurance for my side business. His claim is that I could be sued by my clients if the software I produce does not perform properly or has bugs in it. It seems like a pretty broad claim, but I'm wondering about the truth to it. Can I indeed get sued by someone I do work for if bugs are found? If so, to what amount would I be liable?


Agile Development with 100 Users; is that possible?

We are trying to develop a website that automate an organisation process. This company, let's called it Acme Limited, usually ask their clients to submit paper form and have the clerks to manually enter those form into the internal system. At the moment they have 60 clients across the state. Now, Acme Ltd wants their client to go to their website, that we are building, and fill in the data themselves, instead their clerks. The driver for this, is to free up their clerks, and reassign the clerks to do something else. In my understanding for this scenario - please correct me if I am wrong - the customers in an agile environment, must includes not only the users from the within the company, but also their clients. If we were to develop their system using agile, is it better to include the clients into the software development process ? Have them sit within the development area so that we can ask for their input during development ?


Rewriting IBM assembler + COBOL in C++

I work as a rental agent / manager for a car rental company that is running on a rental system that was written in 1972. I decided that maybe it was time for an update. For a bit of background, here is a short example of the madness that we have to deal with from this program daily: A rental agent must remember that printing on one screen uses "MXC" in the ACT field (everything is based on short codes), which perplexingly stands for "MaXimum display on a Contract", while on another it requires PR (for PRint) in the ACTION field, but several screens use a Y in the PT (for PrinT) field, yet another screen uses Y in the PRT (for PRinT) field, yet another screen requires the user to hit enter (but not the enter next to the letters, as that's a new line character, it must be the enter on the number pad) and then F8, a different but related screen requires simply F8, some screens have a field labeled PRT, which should be for PRinT, but the field actually does nothing and printing is done automatically after going through several prompts, and still more screens have a field labeled PRINT Y/N, which insanely defaults to Y for operations in which another location is already delivering paperwork, and to N for operations in which another dealer will need paperwork. I decided that I could do a better job than this, so I set out to contact the person in the company that would make the decision to update this. I eventually get through to the VP of IT, who is in charge of this program. I get a bit of information out of him, and learn that my car rental company has its rental program written in IBM mainframe assembler with a little bit of COBOL mixed in. He says that there are no positions open right now, but that I should e-mail him my resume anyway (in case something opens up). This leads me to my questions. The first is technical. With the idea of improving maintainability in the future, my thought is to re-write it in a higher-level language than assembly language. My area of experience is in C++, so that is the obvious choice for me. The company is in dire need of an easier way to update the program, as I recently read an article where the man I spoke with is quoted as saying the team worked hard, and they are proud to announce that the program now has support for 5-digit location codes (instead of 4) and 8 digit car numbers (instead of 7). My philosophy on updates, even in situations this dire, is in line with Joel's: http://www.joelonsoftware.com/articles/fog0000000069.html in short, re-writes should be incremental, rather than throwing out everything there was before and starting fresh. Is there an easy way to integrate IBM assembly with C++, and if so, how should I do it? I am vaguely aware of the asm keyword, but I don't know if it's best to use that or do something else. Is such a plan ill-advised? I do most of my work on Linux using g++ and GNU make, so answers specific to that are welcomed, but definitely not required (since I have no idea what sort of build system they have no, but I suspect almost none). The second question is more political. How should I go about persuading this company that they need to make the switch? The theoretical cost savings are huge (based on my estimates, the company is wasting an extra million or so dollars per year, just on increased training costs to learn how to interact with the program), but my proposed changes would probably put all of the current programmers out of work, should they be enacted, so there is great structural resistance to change. edit: I should explain why me modifying what the company already has seems like the best solution to me. I am still open to other suggestions, because this is a monster of a program, however. I've never had a programming job before, so please correct me on any incorrect analysis I might give. First off, there is the off-the-shelf solution. From my talks with a few mid-level managers about this sort of thing, one of the main concerns with switching to a new system is the large number of loyal employees who have been with the company for decades and are comfortable with the system by now. If I have the ability to modify what we have, I could maintain the current interface in a sort of 'compatibility mode'. Users already have to log in to use the current system, so I could add the ability to activate a setting when users log in for the 'first' time (after I make this change), where they are given the option to use either the 'classic' interface or the 'new' interface. There is no way I'll find an off-the-shelf solution that allows that, and I think that fears of senior employees getting confused by changing technology would be a major reason for upper management to say no. My company also owns the software we use; we do not license it. This means that the management I am currently talking to are the same people who could actually authorize me to make a change. With a third-party solution, I would have to get approval from my company in addition to securing whatever rights would be necessary from the company that developed the product we use, which adds an additional hurdle. This would also require convincing the company to give up on "their" product and take some other product, which seems like a greater hurdle than attempting to update what we have, but I could very well be wrong on this issue. Finally, looking into the future, I don't just want to improve the user interface and fix a few bugs. After I update those 'urgent' issues, I was hoping to update fundamental way the company runs as related to technology. After spending 1-2 years on these sorts of issues, my plan was to go back to management and propose more dramatic changes. There are many ways the company runs that could be fundamentally improved by technology that they simply are not using right now. For instance, each region pretty much operates the same way. The local major airport is the central hub to distribute cars. They are primarily sent on an as-needed basis. However, the airport is used as the home base for all operations. They'll send two people in one car to my location to pick up one car from us that we don't need, then return to the airport with the car they came in, plus what they are taking back (we are 32 miles from the airport). Then they will come to the location 5 miles away from us in two cars to drop one of them off, then return in their other car to the airport. They do this even if the car we sent back is the same kind of car they need near us. I've been with the company for about two years now, and I've only seem them deviate from this in the most extreme emergencies of car shortages (so about three times ever). I would replace the 4 people working in every region with an automated scheduling system that determines what cars go where and try and find the path that requires the least amount of time + miles + drivers to deliver all cars where they need to be, as an example of the higher level fixes I hope to some day add. However, before I would feel comfortable proposing all of this, I feel it would be helpful to get a toehold in the company and the code base by doing the smaller tasks, like updating the interface. Solutions like outsourcing or otherwise would remove this possibility.


What Java data structure/design pattern best models this object, considering it would perform these methods?

![Typical Distance between Cities Grid](http://i.stack.imgur.com/nmltT.png) Methods:               1.  getDistance(CityA,CityB) // Returns distance between two cities     2.  getCitiesInRadius(CityA,integer) // Returns cities within a given distance of another city     3.  getCitiesBeyondRadius(CityA,integer) //Returns cities beyond a given distance of another city     4.  getRemoteDestinations(integer) // Returns all city pairs greater than x distance of each other     5.  getLocalDestinations(integer) //Returns all city pairs within x distance of each other


Is there any kind of established architecture for browser based games?

I am beginning the development of a broser based game in which players take certain actions at any point in time. Big parts of gameplay will be happening in real life and just have to be entered into the system. I believe a good kind of comparison might be a platform for managing fantasy football, although I have virtually no experience playing that, so please correct me if I am mistaken here. The point is that some events happen in the program (i.e. on the server, out of reach for the players) like pulling new results from some datasource, starting of a new round by a game master and such.   Other events happen in real life (two players closing a deal on the transfer of some team member or whatnot - again: have never played fantasy football) and have to be entered into the system. The first part is pretty easy since the game masters will be "staff" and thus can be trusted to a certain degree to not mess with the system. But the second part bothers me quite a lot, especially since the actions may involve multiple steps and interactions with different players, like registering a deal with the system that then has to be approved by the other party or denied and passed on to a game master to decide. I would of course like to separate the game logic as far as possible from the presentation and basic form validation but am unsure how to do this in a clean fashion. Of course I could (and will) put some effort into making my own architectural decisions and prototype different ideas. But I am bound to make some stupid mistakes at some point, so I would like to avoid some of that by getting a little "book smart" beforehand. So the question is: **Is there any kind of architectural works that I can read up on?**   Papers, blogs, maybe design documents or even source code? Writing this down this seems more like a business application with business rules, workflows and such... Any good entry points for that? * * * # EDIT: After reading the first answers I am under the impression of having made a mistake when including the "MMO" part into the title. The game will _not_ be all fancy (i.e. 3D or such) on the client side and the logic will completely exist on the server. That is, apart from basic form validation _for the user_ which will also be mirrored on the server side. So the target toolset will be **HTML5, JavaScript** , probably JQuery(UI). My question is more related to the software architecture/design of a system that enforces certain rules. ## Separation of ruleset and presentation One problem I am having is that I want to separate the game rules from the presentation. The first step would be to make an own module for the game "engine" that only exposes an interface that allows all actions to be taken in a clean way.   If an action fails with regard to some pre/post condition, the engine throws an exception which is then presented to the user like "you cannot sell something you do not own" or "after that you would end up in a situation which is not a valid game state." The problem here is that I would like to be able to not even present invalid action in the first place or grey out the corresponding UI elements. ## Changing and tweaking the ruleset Another big thing is the ruleset. It will probably evolve over time and most definitely must be tweaked. What's more, it should be possible (to a certain extent) to build a ruleset that fits a specific game round, i.e. choosing different kinds of behaviours in different aspects of the game. This would do something like "we play it with extension A today but we throw out extension B." For me, this screams **"Architectural/Design pattern"** but I have no idea on who might have published on something like this, not even what to google for.


Is physical Agile board "always" better than electronic tool?

Whenever the question comes up on which Agile tool to use use there always some people that answer "don't use an electronic tool because you will lose the big-visible-board advantage which better generate team conversation". Is this always the case or are there any contexts where an electronic tool is a better choice? What are some of the pros and cons of each approach?


Dependency injection with n-tier Entity Framework solution

I am currently designing an n-tier solution which is using Entity Framework 5 (.net 4) as its data access strategy, but am concerned about how to incorporate dependency injection to make it testable / flexible. My current solution layout is as follows (my solution is called Alcatraz): **Alcatraz.WebUI** : An asp.net webform project, the front end user interface, references projects _Alcatraz.Business_ and _Alcatraz.Data.Models_. **Alcatraz.Business** : A class library project, contains the business logic, references projects _Alcatraz.Data.Access_ , _Alcatraz.Data.Models_ **Alcatraz.Data.Access** : A class library project, houses _AlcatrazModel.edmx_ and `AlcatrazEntities` DbContext, references projects _Alcatraz.Data.Models_. **Alcatraz.Data.Models** : A class library project, contains POCOs for the Alcatraz model, no references. My vision for how this solution would work is the web-ui would instantiate a repository within the business library, this repository would have a dependency (through the constructor) of a connection string (not an `AlcatrazEntities` instance). The web-ui would know the database connection strings, but not that it was an entity framework connection string. In the Business project:               public class InmateRepository : IInmateRepository     {         private string _connectionString;              public InmateRepository(string connectionString)         {             if (connectionString == null)             {                 throw new ArgumentNullException("connectionString");             }                  EntityConnectionStringBuilder connectionBuilder = new EntityConnectionStringBuilder();                  connectionBuilder.Metadata = "res://*/AlcatrazModel.csdl|res://*/AlcatrazModel.ssdl|res://*/AlcatrazModel.msl";             connectionBuilder.Provider = "System.Data.SqlClient";             connectionBuilder.ProviderConnectionString = connectionString;                  _connectionString = connectionBuilder.ToString();         }              public IQueryable<Inmate> GetAllInmates()         {             AlcatrazEntities ents = new AlcatrazEntities(_connectionString);                  return ents.Inmates;         }     }      In the Web UI:               IInmateRepository inmateRepo = new InmateRepository(@"data source=MATTHEW-PC\SQLEXPRESS;initial catalog=Alcatraz;integrated security=True;");          List<Inmate> deathRowInmates = inmateRepo.GetAllInmates().Where(i => i.OnDeathRow).ToList();      I have a few related questions about this design.   1. Does this design even make sense in terms of Entity Frameworks capabilities? I heard that Entity framework uses the Unit-of-work pattern already, am I just adding another layer of abstract unnecessarily?   2. I don't want my web-ui to directly communicate with Entity Framework (or even reference it for that matter), I want all database access to go through the business layer as in the future I will have multiple projects using the same business layer (web service, windows application, etc.) and I want to have it easy to maintain / update by having the business logic in one central area. Is this an appropriate way to achieve this?   3. Should the Business layer even contain repositories, or should that be contained within the Access layer? If where they are is alright, is passing a connection string a good dependency to assume? Thanks for taking the time to read!


Do LAMP/Java-based software development teams have SOE's?

As a developer on the Windows/.NET stack, it's pretty normal for the company- supplied machine to come with Windows (usually an ancient, archaic version like Windows XP) and a stack of software pre-installed as part of a Standard Operating Environment. In companies building software on the Java/Ruby/PHP/C stack using Linux/Unix/BSD as a primary OS, in your experience:   1. Does everyone tend to use the same OS/version?   2. How do you ensure everyone is using the same version of libraries/dependencies/tools (do you?)   3. How do you create an SOE to pre-configure a machine (do you?)


What it is a data structure of a certain type called?

I'll try to keep this as much language agnostic as I can but I'll give the examples in C# since I now know how to solve it that language. The question came to mind when I was thinking of how could I instantiate many objects of the same type. Lets say I wanted to create one rectangle, I would do: `Rectangle rect1 = new Rectangle()` Now, if I wanted to create 2 I would do.               Rectangle rect1 = new Rectangle()     Rectangle rect2 = new Rectangle()      This of course is not efficient when you need to create many rectangles. The problem is, I couldn't use loops just like that to create a many rectangles:               for (int i = 0; i < 100; i++){         Rectangle rect1 = new Rectangle()     }      This obviously doesn't achieve what I am after since I would just create 100 `rect1`'s. I was pointed out that you could do something like this: Thanks mootinator               var rectangles = new Rectangle[100];     for (int i = 0; i < 100; i++){       rectangles[i] = new Rectangle();     }      For what I understood, the code creates a data structure (Array? ArrayList?) of they type `Rectangle` inside you actually "store" Rectangles. The hardest thing for me was putting a question for _this_. So the questions are:   1. What is this called?   2. Is this standard / "common" in most OOP based languages? The question actually came up in ActionsScript 3, but is is useful /necessary in any language it might seem.   3. Is this the best way for doing this considering that I would the like to, for example, loop this Array and apply a method `.Move()`.   4. Are there? and what are the other options to do this.


Storing and maintaining serialized objects in C#

What are the best practices to store and maintain serialized objects in C#? Any strategies or patterns that apply? What I have come to believe so far is this:   * Prefer Json over XML, both for space and for speed, but xml is easier to query/mine data via LINQ to XML for bigger data sets.   * For every single property, map explicitly to a serialized name. In the future, when you need to rename a property, your serialized data won't break. Attributes help with this.   * Store some kind of version info on the serialized object, in case you need to mass-migrate data in the future **Update:** (that I found out the hard way)   * Store all datetimes in a uniform way throughout the whole application and throughout all versions. Both concerning format and time zone.


How to avoid shooting yourself in the foot when using closure in JavaScript

The closure feature is widely used in JavaScript and make it quite difficult for programmer who was used to program in a no-closure language. So what is the best practice about using closure and how to avoid shooting yourself in the foot.


What are the different considerations to make when determining persistent data format?

I've recently been struggling with the concept of what file structure to use when creating save-files for a desktop applications. When I say "save-files" I mean something like *.doc files. Files that contain the work that the user put into the program and want to be able to load and resume their work at a later time. Things like binary serialization are easy, though if and when the model for the applications gets re-factored or expanded, that breaks (I believe) the files saved with the older format. Things like XML and JSON are more resilient to future change, but I feel like I'm falling into the trap of using XML as my "golden hammer" so-to-speak. A database seems overkill for basically all of the applications I develop. What are some common options, and I'm sure there's many, that I'm not considering? Can you describe when each of these options is best used and why its the best choice?


Linked list clarification

This is a pretty simple question but I'm new to java. The linked list found in java.util.LinkedList. I saw elsewhere that Java does not use pointers... When I create a new list and add new elements to it, does the list contain references to the data and to the next/previous elements or does it also contain the object itself.


Is it reasonable to null guard every single dereferenced pointer?

At a new job, I've been getting flagged in code reviews for code like this:               PowerManager::PowerManager(IMsgSender* msgSender)       : msgSender_(msgSender) { }          void PowerManager::SignalShutdown()     {         msgSender_->sendMsg("shutdown()");     }      I'm told that last method should read:               void PowerManager::SignalShutdown()     {         if (msgSender_) {             msgSender_->sendMsg("shutdown()");         }     }      i.e., I _must_ put a `NULL` guard around the `msgSender_` variable, even though it is a private data member. It's difficult for me to restrain myself from using expletives to describe how I feel about this piece of 'wisdom'. When I ask for an explanation, I get a litany of horror stories about how some junior programmer, some-year, got confused about how a class was supposed to work and accidentally deleted a member he shouldn't have (and set it to `NULL` afterwards, apparently), and things blew up in the field right after a product release, and we've "learned the hard way, trust us" that it's better to just `NULL` check _everything_. To me, this feels like cargo cult programming, plain and simple. A few well- meaning colleagues are earnestly trying to help me 'get it' and see how this will help me write more robust code, but... I can't help feeling like they're the ones who don't get it. Is it reasonable for a coding standard to require that _every single_ pointer dereferenced in a function be checked for `NULL` first—even private data members? (Note: To give some context, we make a consumer electronics device, not an air traffic control system or some other 'failure-equals-people-die' product.) **EDIT** : In the above example, the `msgSender_` collaborator isn't optional. If it's ever `NULL`, it indicates a bug. The only reason it is passed into the constructor is so `PowerManager` can be tested with a mock `IMsgSender` subclass. **SUMMARY** : There were some really great answers to this question, thanks everyone. I accepted the one from @aaronps chiefly due to its brevity. There seems to be fairly broad general agreement that:   1. Mandating `NULL` guards for _every single_ dereferenced pointer is overkill, but   2. You can side-step the whole debate by using a reference instead (if possible) or a `const` pointer, and   3. `assert` statements are a more enlightened alternative to `NULL` guards for verifying that a function's preconditions are met.


Android design advice - services & broadcast receivers

I'm in the process of learning the Android SDK and creating some projects to get a grasp on the system. The current project I'm working with works just fine but I'd like to get some advice about other ways I can go about designing it. Here's what it needs to do. When a text message is received from a specific number, it should fire off a toast message that repeats at a certain interval for a specific duration.   1. To make this work, I created an SMS BroadcastReceiver and checked the incoming messages for the number I'm looking for.    2. If found, an IntentService would be started that would pull out the interval and duration from saved shared prefs. The IntentService would then fire off a broadcast.   3. The BroadcastReceiver for this would catch it and use the AlarmManager to handle the toast message repetitions. This all works just fine, but I'm wondering if there's a cleaner or more efficient way of going about doing this? Any suggestions or advice?


ORM domain design pitfalls

Are there any patterns which seem sensible when designing an object oriented domain, but do not translate nicely onto a relational database schema? If so, are there standard patterns that can be used instead?


Is it OK to have a team with same abilities but different skill levels?

I believe that in an ideal team, members should have different but complementary abilities. But is that true about software development teams? As an example we are a small team of 5. We almost have the same abilities and interests but with different levels of skills. Regarding such situation I think we don't cover our teammates' weaknesses.   * Is there any pattern to follow to manage and improve such team?   * Should I setup a team with different abilities and interests to maximize the performance and productivity? \-- EDIT -- Our current team has a specific lifetime. We work together in a per-project manner. In another word we may change the team arrangement for each project depending on the project and developers situation. Actually we've provided a sort of floating situation. In short, we are a network of developers rather than a fixed-size development team.


Trying to sort the coefficients of the polynomial (z-a)(z-b)(z-c)...(z-n) into a vector

So I have a factored polynomial of the form (z-a)(z-b)(z-c)...(z-n) for n an even positive integer. Thus the coefficient of z^k for 0 <= k < n will be the sum of all distinct n-k element products taken from the set {a,b,...,n} multiplied by (-1)^k, I hope that makes sense, please ask if you need more clarification. I'm trying to put these coefficients into a row vector with the first column containing the constant coefficient (which would be abc...n) and the last column containing the coefficient for z^n (which would be 1). I imagine there is a way to brute force this with a ton of nested loops, but I'm hoping there is a more efficient way. This is being done in Matlab (which I'm not that familiar with) and I know Matlab has a ton of algorithms and functions, so maybe its got something I can use. Can anyone think of a way to do this? Example: (z-1)(z-2)(z-3) = z^3 - (1 + 2 + 3)z^2 + (1*2 + 1*3 + 2*3)z - 1*2*3 = z^3 - 6z^2 + 11z - 6. Note that this example is n=3 odd, but n=4 would have taken too long to do by hand. Edit: Let me know if you think this would be better posted at TCS or Math Stack Exchange.


Options for programming by contract in Java

I am working on a project (which includes JavaEE web apps and JavaSE apps) that has grown from a single developer to a team of three, and issues of readability and robustness are starting to emerge. One glaring omission from the Java language has been fine tuned contracts, and how easily these are exposed to other developers. (By contracts I mean mostly validating method parameters and object pre/post conditions). There are a few solutions that I am looking at, and I would like to get some feedback from others who have some practical experience. It would seem that Java currently has two supported ways to define a contracts:   1. The assert statement   2. Throwing exceptions (such as IllegalArgumentException) Asserts seem to only have value as a debugging tool. Since asserts are not enabled by default, the expectation is that developers will only rely on them during some formalized testing period, after which they are ignored. Throwing exceptions seems like a robust option in that they allow almost any kind of checks to be made. However, the range of exceptions defined by the Java library seem to be poorly suited to defining contracts (for examply subclasses of IllegalArgumentException don't specifically with range issues, null checks etc, and subclasses of IllegalStateException appear to be concerned with network connection and file states), which forces each group to define their own range of exception classes. But the biggest problem is that neither asserts nor exceptions explicitly map contract requirements to parameters or concepts like pre and post conditions. It is expected that the developer will manually maintain the JavaDoc comments with the code to make it clear under what conditions an assert will fail or an exception will be thrown. It is clear to me that the standard Java libraries don't adequately support design by contract, which brings me to my questions: Are my assumptions above correct, or have I missed some property of asserts and exceptions that actually makes them quite useful for this kind of problem?


How should I log time spent on multiple tasks?

In Joel's blog on evidence based scheduling he suggests making estimates based on the smallest unit of work and logging extra work back to the original task. The problem I'm now experiencing is that I'll have create object A with subtask method A which creates object B and test all of the above. I create tasks for each of these that seems to be resulting in ok-ish estimates (need practice), but when I go to log work I find that I worked on 4 tasks at once because I tweak method A and find a bug in the test and refactor object B all while coding it. How should I go about logging this work? should I say I spent, for example, 2 hours on each of the 4 tasks I worked on in the 8 hour day?


How is "SELECT *" read in English?

The other day, a friend told me that in USA, they pronounce SQL like _squel_ , not _es-qu-el_. I was surprised. I was wondering how "SELECT *" is read/pronounced while talking.   * select star?   * select asterisks?   * select all?


What's a good algorithm for a random, uneven distribution of a fixed amount of a resource?

### Problem I have **X** , a positive integer, of some resource, **R**. There are **N** potential targets. I want to distribute all of **R** to the **N** targets in some "interesting" way. "Interesting" means:   * Some targets may not get any **R**.   * It should rarely be near even (with a majority of target getting near **X/N** of the resource).   * There should be at least a small chance of one target getting all of **R**. * * * ### Bad solutions The naive approach would be to pick a random target and give one **R** to it and repeat **X** times. This would result in too even of an approach. The next idea is to pick a random number between 1 and **X** and give it to a random target. This results in too large of a number (at least **X/2** on average) being given to one target. ### Question This algorithm will be used frequently and I want the distribution to be interesting and uneven so that the surprise doesn't wear off for users. Is there a good algorithm for something in between these two approaches, that fits the definition of _interesting_ above?


What implementation problems are still soaking up all of your time?

What implementation problems has the industry claimed to have solved many times, but are still soaking up all of your time? Examples:   * Cross platform GUI - mobile devices have blown this issue wide open.   * OO to RDBMS mapping - how do I map this attribute to that field in that database using that framework. You get the idea.   * Interface definitions - ..., CORBA, COM, EJB, WSDL, ..., etc Can you think of any others?


Perks for new programmers

I intend on hiring 2-3 junior programmers right out of college. Aside from cash, what is the most important perk for a young programmer? Is it games at work? I want to be creative... I want some good ideas


How can a commercially-driven open source project build an open source community?

I'm working on an ambitious, commercially-driven open source project* (it probably falls under Wikipedia's definition of Open Core). I'm an engineer on the project, so I don't have too much sway over all of our policies. The majority of the code is in public projects on GitHub, and we have public mailing lists, but that's pretty much the extent of our open source engagement. We use the mailing lists to respond to questions from the community, but a lot of topics go unanswered because they are low quality or because we have deadlines and we don't want to spend too much time on the mailing list instead of delivering features. We have a corporate-mandated contributor agreement that is more like a contributor deterrent IMO. We currently few or no passionate community members who feel strongly enough to represent our support as a volunteer. I've been able to find a few guides (Producing Open Source Software was perhaps the best) about building open source communities, but all of them are under the premise that a project is pure open source with the ability to be transparent to the community. For the things I've described above, I know we can do better, but I don't know that I will be able to get management's buy-in on any of those. What kind of things can a commercial open source project do to engage and build an open source community? * * * *(I've intentionally _not_ explicitly named the project; the views in this question are my own and do not necessarily represent the views of the rest of my team or my employer.)


Automated testing of programs with graphical output

I am a lecturer for a post-graduate module where I expect my students to write Python code that replicates examples from the textbook. The project has been running for a couple of years and this year I want to introduce more automated testing. The problem is writing tests for the functions which primarily produce a matplotlib figure. Note that we are only trying to replicate the figures approximately, so binary comparison with a target image won't be very useful. The short question is therefore: what strategies can I use to test programs whose primary graphical output can not be compared against a strict reference image? Some of the problems that I have with the existing code base that prevents automated testing in this case:   * Producing the graph stops execution in many cases   * It is not practical to generate a copy of the figure in the textbook that includes annotations and so on, so algorithmic image comparison is unlikely to be the answer. To clarify my goals:   1. I would like to be able to _execute all the code in the codebase_ to check that it is actually running, even if that means throwing away the output. This would catch regressions where a function is changed    2. Instead of investing deeply into fuzzy matching of the graphical output with the target, I believe that _visual checking_ between a reference image and the generated image is probably going to be the simplest, but this should be deferred to happen once at the end of the run rather than during the run   3. Since this is a collaborative project, I don't have to assume that the students are going to be adversarial. Mistakes will be good-faith rather than perverse.


How do I design a DAL when I have to deal with relationships?

Say I'm developing a bug tracker, where a ticket _belongs to_ at most one milestone, and a milestone can _have many_ tickets. When a milestone is deleted (from the database), all tickets associated with that milestone must have their relationship unset (i.e. set to `null`). This is a simple relationship. The classes are fairly simple, and map directly to a database:               public class Ticket {         public ObjectId Id { get; set; }         public string Title { get; set; }         public ObjectId MilestoneId { get; set; }     }          public class Milestone {         public ObjectId Id { get; set; }         public string Title { get; set; }     }      Now comes the tricky part: where and how do I reset the `MilestoneId` fields? One possible solution is to write a data access layer by creating one giant class with all data accessing methods for all kinds of objects, in this case tickets and milestones. Another possible solution is to write several classes (e.g. `TicketProvider` and `MilestoneProvider`), one for each kind of object, that provide data accessing methods such as `Find`, `Save` and `Destroy`. The latter appeals more to me since I don't like monsterous classes, but there is one caveat: the method that deletes milestones has to reset the `MilestoneId`s of all associated tickets to `null`. This means that `MilestoneProvider`, which is responsible for manipulating milestones, suddenly deals with tickets! How are relationships commonly dealt with in data access layers, and how can I prevent violation of SRP? Should I put the entire DAL in one class, or should I separate it and if so, how can I best do that?


Should database queries be abstracted out of the page itself?

When writing page generation in PHP, I often find myself writing a set of files littered with database queries. For example, I might have a query to fetch some data about a post directly from the database to display on a page, like this:               $statement = $db->prepare('SELECT * FROM posts WHERE id=:id');     $statement->bindValue(':id', $id, PDO::PARAM_INT);     $statement->execute();     $post = $statement->fetch(PDO::FETCH_ASSOC);     $content = $post['content']     // do something with the content      These quick, one-off queries are usually small, but I sometimes end up with large portions of database interaction code which begins to look pretty messy. In some cases, I've solved this problem by creating a simple library of functions to handle my post-related db queries, shortening that block of code to a simple:               $content = post_get_content($id);      And that's great. Or at least it is until I need to do something else. Maybe I need to get the five most recent posts to display in a list. Well, I could always add another function:               $recent_posts = post_get_recent(5);     foreach ($recent_posts as $post) { ... }      But that ends up using a `SELECT *` query, which I usually really don't need anyway, but is often too complicated to reasonably abstract. I eventually end up with either a massive library of database interaction functions for every single use case, or a series of messy queries inside every page's code. And even once I've built these libraries, I'll find myself needing to do one tiny join that I hadn't used before, and I suddenly need to write another highly- specialized function to do the job. Sure, I could use the functions for general use cases and queries for specific interactions, but as soon as I start writing raw queries I begin to slip back into direct access for everything. Either that, or I'll get lazy and will start doing things in PHP loops that should really be done directly in the MySQL queries, anyway. I'd like to ask those more experienced with writing internet applications: is the maintainability boost worth the extra lines of code and possible inefficiencies that the abstractions may introduce? Or is simply using direct query strings an acceptable method for handling database interactions?


What is the difference between an engineer and a product manager?

It seems nowadays all the develop teams have both software engineers and product manager. I am a newbie to the software industry and I wonder what is the difference?   1. Is it necessary for a Product Manager to have a programming background?   2. How to divide work between Engineers and Product Manager?


Should QA find reproducible scenarios?

Sometimes my QA team reports bugs, but neither I or them have any idea on how to reproduce them. This leads to very long and frustrating debugging sessions which sometimes do not even yield results. My software is tied heavily with proprietary hardware so bugs can come from many directions at once. Should I expect more from them than "your software crashed when I pressed a button" or should I figure myself what happened? EDIT: One of my coworker pointed out that we are probably all developers here so the results might suffer a little bias


Where can I safely learn about computer security?

I find it really hard to find resources about computer security. I asked questions on message boards about key loggers and viruses and I got negative assumption from people assuming the the worse. Also, I don't think that I can trust random message boards. I know that it is a broad topic, but are there any good websites that I can follow and learn from that are targeted to beginner with some samples? I am a developer (or at least want to be one) and I have a CS degree if that helps.


What is the reason for using lowercase for the first word in a local variable (eg, employeeCount, firstName)

I take a good deal of criticism from other programmers due to my use of full proper casing for all my variables. For example, your typical programmer will use `employeeCount` for a variable name, but I use `EmployeeCount`. I use full proper casing for _everything_ , be it a void method, return method, variable, property, or constant. I even follow this convention in Javascript. That last one _really_ rustles people's jimmies. The typical reason given as to why I shouldn't follow this "non-standard" casing convention is because full proper case should be reserved for properties and void methods. Local variable and methods that return a value should have the first word in lowercase like `int employeeCount = getEmployeeCount()`. However, I don't understand why. When I question this, it seems that I just get an arbitrary answer of _that's the standard_. Whatever the answer is, it usually always boils down to _That's just the way it is and I don't question it. I just follow it._. Arbitrary answers are never good enough for me. Ever since my early days of programming Excel 97 macros with the Office IDE, I've never needed a casing convention to tell me whether or not something is a local variable or property. This is because I've always used a very intuitive naming convention. For example, `GetNuggetCount()` clearly suggests a method that goes somewhere an gets a count of all the nuggets. `SetNuggetCount(x)` suggests that you are assigning a new value to the count of nuggets. `NuggetCount` all by itself suggests a property or local variable that is simply holding a value. To that last one, one may be tempted to say, "Ah ha! That is the question. Property or variable? WHICH IS IT?" To that, I'd reply with, "Does it really matter?" So here's the tl;dr;: What are the objective, logical, non-arbitrary reasons to use lowercase for the first word in your variable or return method? **Edit:** For MainMa Replace _this_ code with the first code sample in your answer and see how well your argument holds up:               public void ComputeMetrics()     {         const int MaxSnapshots = 20;              var Snapshots = this.LiveMeasurements.IsEnabled ?             this.GrabSnapshots(MaxSnapshots, this.cache) :             this.LoadFromMemoryStorage();              if (!Snapshots.Any())         {             this.Report(LogMessage.SnapshotsAreEmpty);             return;         }              var MeasurementCount = Measurements.Count();         this.Chart.Initialize((count + 1) * 2);              foreach (var s in Snapshots)         {             this.Chart.AppendSnapshot(s);         }     }


How Should "Undo Typing" Behave?

I'm implementing a Java app that includes an Undo/Redo stack. I've noticed that some apps (such as TextEdit on Mac OS X) let you choose "Undo Typing" from the Edit Menu after typing some text. I'd like to implement that sort of thing into my app as well, but I'm having a really hard time finding guidelines about how it should behave. With some trial and error, my best guess about how TextEdit's Undo Typing behaves is:   * When the user types a new character (or types the delete key), merge it into the previous Undo Typing item if one is at the top of the Undo stack, unless one of the following situations occurs   * Always create a new Undo Typing item after the user continues to type after at least 15 seconds of inactivity   * Always create a new Undo Typing item after the user is typing for an extended period of time and some condition is met (couldn't figure out if this was time based or character count based).   * Always create a new Undo Typing item when any text is selected and then deleted or overwritten (selecting text, not making a change, then returning to the original insertion point and continuing to type does not trigger this) In practice, Apple's strategy seems to work (at least it works for me when I type), but as noted by the last point, I haven't really been able to figure out the rules. Also, it seems like other programs follow different rules, such as Microsoft Word. Google has not turned up a defined list of rules for any implementation of Undo Typing and I haven't come across any best practices for how it should behave. So how should it behave? Or is it just up to the whims of the programmer? EDIT: Just to clarify, I'm not interested in implementation details right now. I'm especially curious as to whether or not an authoritative reference (e.g. best practices or user interface document) exists describing this or a description of how it is implemented across multiple products.


Is bash "finished"?

Should bash be expected to change in ways that break non-trivial amounts of existing scripts at some point in the (near/<5y) future? How much change has it gone trough in the last ten years compared to, say, python or perl?


Are SQL Injection vulnerabilities in a PHP application acceptable if mod_security is enabled?

I've been asked to audit a PHP application. No framework, no router, no model. Pure PHP. Few shared functions. HTML, CSS, and JS all mixed together. I've discovered numerous places where SQL injection would be easily possible. There are other problems with the application (XSS vulnerabilities, rampant inline CSS, code copy-pasted everywhere) but this is the biggest. Sometimes they escape inputs, not using a prepared query or even mysql_real_escape_string(), mind you, but using addslashes(). Often, though, their queries look exactly like this (pasted from their code but with columns and variable names changed):               $user = mysql_query("select * from profile where profile_id='".$_REQUEST["profile_id"]."'");      The developers in question claimed that they were unable to hack their application. I tried, and found mod_security to be enabled, resulting in HTTP 406 for some obvious SQL injection attacks. I believe there to be sophisticated workarounds for mod_security, but I don't have time to chase them down. They claim that this is a "conceptual" matter and not a "practical" one since the application can't easily be hacked. Their internal auditor agreed that there were problems, but emphasized the conceptual nature of the issues. They also use this conceptual/practical argument to defend against inline CSS and JS, absence of code organization, XSS vulnerabilities, and massive amounts of repetition. My client (rightly so, perhaps) just wants this to go away so they can launch their product. The site works. You can log in, do what you need to do, and things are visibly functional, if slow. SQL Injection would indeed be hard to do, given mod_security. Further, their talk of "conceptual vs. practical" is rhetorically brilliant, considering that my client doesn't understand web application security. I worry that they've succeeded in making me sound like an angry puritan. In many ways, this is a problem of politics, not technology, but I am at a loss. As a developer, I want to tell them to toss the whole project and start over with a new team, but I face a strong defense from the team that built it and a client who really needs to ship their product. Is my position here too harsh? Even if they fix the SQL Injection and XSS problems can I ever endorse the release of an unmaintainable tangle of spaghetti code? **EDIT:** As to my role on this project, I'm not a security expert, I'm a web developer generalist. the client initially asked me to load test the app and make recommendations for scalability. I haven't gotten that far yet, because when I first read the output of the home page, I saw inline CSS, table based layouts, and all sorts of crazy JS, so I requested a copy of the code, where I found the unholy mess described above. They don't even abstract the HTML header and footer. Every PHP file has a slightly different pasted version. And as to the app itself, it does store personal information, and it processes (but does not store) credit card data.


How to implement a no-login authentication system

I am looking to build a very loose authentication system that can track a user and link submitted data/comments to a specific user. The submissions are essentially anonymous, but a user may want to edit his submission/comment at a later date. I want the experience to be as smooth as possible so do not want to ask users to sign up for an account and then login each time. There is no point as their submissions are not in their name and to another user browsing the site, there is no way of linking a submission to a specific user (think anonymous comments on a blog post or pastie). However, the user should have the ability to edit (at least in the short term) the content they have posted. The way I imagine doing this would be to place a unique identifier in a cookie on the users machine. This would enable me to link a submission to a user, and while that cookie remained on the users machine, I would allow them to edit their content. Of course, if the cookie is lost, or the user accesses the site from a different browser, then they would not be able to edit their content, but this is not really an issue, they can always resubmit a new piece of content. Is there a better way of doing this? How can I implement this so that the user can edit their data for the longest possible amount of time.


SharePoint Versus WordPress for developing business web sites

We have been using sharePoint server 2013 to build out intranet web application including, discussion forum, wiki library, calendars, announcements ,etc. Now a new requirement has been raised from the management that we want to build a new external web site for our company, including the following main sections; contact us , about us, services, our team member, our customers, etc. at this stage I am trying to find the best tool that we can use to build our website. Either using SharePoint 2013 or WordPress. So can anyone advices on what are the advantages and disadvantages of each tool? Regards


Why do development devices give you more resources than a typical device?

I have created an app that works on my 4th generation iPod Touch and my company's 5th generation iPod touch. We were about to release, when we found a crash that occurs after any non- developer device runs the app*. The notion came up that a device registered as a 'developer device' gives your app more resources to use. This doesn't seem right to me, since I couldn't think of any reason that would exist - I feel like it is more likely an issue with building or provision profiling. However, that prompted a discussion. Why do devices such as game console development kits, devices that have more capabilities than the target platform, exist in the first place? Of course it is nice to stress test a program, but wouldn't a more accurate representation of the target platform make more sense? TL;DR - Why do development kits have more resources than target platforms? *With a non-developer device being any >3rd gen. iOS device that downloads the app from our server, not directly from a computer with the app & xcode installed. Note there is another question that reads similar, but it is actually different, because that other question is asking about simulator, and I understand that there are massive differences between using a simulator and an actual device.


Didn't do too well on a Java IKM test, advice?

I did an IKM Java test recently and got quite a low score. I only graduated a year ago and I dont have commercial experience in Java (i do web development in my current job). I thought reading up a lot on Java would help me prepare, but when I sat the IKM test i got ripped to pieces. I didn't know much about how the garbage collection actually works, names of other java compilers (i know about javac?), using .dll with Java etc etc. I know a wide range of the basics, but to the extent wether 'int(5L)' produces an integer or not, I really didnt know. My question is that many of the IKM questions I have never come across, yet I have read many of the wider-known Java programming books (Deitel, O'Reilly etc). Am i reading the wrong books??? Could anyone recommend a good plan of action to allow me to go away and self- study and be able to know these really tough java questions?


How to unit test a jsp file?

I'm developing a Java 6 EE application and I'm testing my jsp code with another one with a testing version of the function calls and code used in the original one but it seems loose and impractical. Is there a good way to accomplish this kind of testing?


Are Bools/Bits Faster Than Integers

As the title suggests I'm wondering whether bools or bits are faster than using integers (1 and 0)? Specifically I thinking about their speed in CASE statements, even more specifically in T-SQL (although it would be interesting to hear about experiences from other languages). For some context, I have a pretty big SELECT statement over a large table which has to transform a lot of data based on integer being either 1 or 0, and was considering converting the integers to bits for a performance boost. EDIT: Thank you all for your responses. It kind of seemed like you were all giving me pretty much the same advice worded slightly differently or with different levels of detail.


Data indexing frameworks fit for large E-Commerce applications

we wrote and still maintain a large E-Commerce application. Our feature list resembles what you would expect from most shops. We'd like to improve some of our features, and now the search/suggestion list functionality (enter some letters, a JScripted suggestion list appears) has caught our eye. Currently, we use http://xapian.org/. It has some drawbacks. Firstly, it's not actually the right solution. It has been created to index documents, not ever- changing data in a granularity that an E-Commerce application would need. Secondly, the load on the database is significant when we reindex all data every night. We'd like a framework that has been designed for indexing database data, which can add to the index easily and without much load, which can supply data changes in the backoffice quickly to the frontend without much load and delay. I'm aware of the fact that Xapian is Open Source and even Free Software, so we could adapt it to our needs if we decided to invest the time and manpower. But taking a quick look around for a solution more suited seems fair, right? Oh, and commercial applications are fine, too. FOSS is not required.


Should I tell someone that their commit caused a regression?

When you track down and fix a regression—i.e. a bug that caused previously working code to stop working—version control makes it entirely possible to look up who committed the change that broke it. Is it worth doing this? Is it constructive to point this out to the person that made the commit? Does the nature of the mistake (on the scale of simple inattentiveness to fundamental misunderstanding of the code they changed) change whether or not it's a good idea? If it is a good idea to tell them, what are good ways to do it without causing offense or causing them to get defensive? Assume, for the sake of argument, that the bug is sufficiently subtle that the CI server's automated tests can't pick it up.


Dynamic items on JavaFX interface

I am looking to build an application similar to Blocky. For that I will be using JavaFX. I am working on prototypes atm. It appears that JavaFX UIs are generally made using Scene Builders. I am still not sure how much flexibility is this going to provide me, when I will be looking to dynamically change shapes (make them bigger etc) during runtime, detect collisions to connect shapes etc. Could someone more experienced using this technology tell me how feasible an application like this is using JavaFX? Also would it be easier/same to do it with Java? Thanks.


What stressors do programmers encounter on the job, and how do you deal with them?

Learning to manage stress is vital to staying healthy while working at any job. A necessary subtask is learning to recognize and limit the sources of stress. But, in the midst of the daily grind, it can be difficult to recognize sources of stress (especially for an intense, focused persona such as a programmer). What types of stressors should programmers look out for, and how can they be managed?


Why there are no PUT and DELETE methods in HTML forms?

HTML4 / XHTML1 allows only GET and POST in forms, now it seems like HTML5 will do the same. There is a proposal to add these two but it doesn't seem to be gaining traction. What were the technical or political reasons for not including PUT and DELETE in HTML5 specification draft?


Should an analysis be technology-agnostic?

I had an argument yesterday with one of my colleagues. He (a business-analyst, previously a programmer) thinks that he should be aware of the technology used to implement the system, so he can take better design decisions. In my opinion (I am a programmer), an analysis should not be coupled in any way to the technology and I believe that a good analyst can make a great design without worrying about the implementation details. Am I right to think that way? Are there any reasons why a business analyst would need to know the technology used to implement the system? EDIT : I believe that I used the wrong term when saying `business analyst`. Maybe I meant architect, or system analyst. I am not used to these terms. I meant something like architect or system analyst if you prefer. Thank you everyone for your awesome answers! I am not very experienced yet and I am glad you opened my eyes on this.


Sites for co-funding open source projects

I am thinking about helping to finance an adaptation of Postgres to utilize the GPU for sequential scans. To reduce my cost, I would like to get others who are interested in the same feature to co-fund it with me. I have come across a few sites facilitating such financing, but as none of the ones I looked at had facilitated the financing of more than a few projects, I did not even bookmark their URLs. **My question** What are the best sites to do this? The sites needs to be active. **EDIT:** The best thing would be if coders could also commit to contribute, either by developing, testing, documenting or doing other work.