title: What makes for "good style" in Java?

text: I had asked this question on Stackoverflow, and before it got booed off, I received the helpful suggestion from Péter Török that this might be a better place to post it. I've been programming in Java for a few years. I've often discussed design decisions with colleagues on the basis of what constitutes 'good style'. Indeed, there are a number of StackOverflow questions/answers that discuss a design on the basis of whether something is 'good style'. But what makes 'good style'? Like many things, I know it when I see it... but I wanted to have better idea than just my conscience saying that this design doesn't feel right. What are the things you think about in order to produce good, well designed code? (I acknowledge that this is somewhat subjective, as what is 'good style' will depend on the task at hand). (Also, I should add that I'm not interested in team styles - e.g. "we use indents of 2 spaces rather than 4"..., and I'm not interested in the Java code conventions.) Edit: thanks for all the good answers/comments so far. I'm especially keen for answers that would help codify those things that make a programmer's conscience (and possibly stomach) wrench?


title: Is there a GPL-compatible software license for libraries which allows static linking, but requires redistribution of library source code?

text: I'm looking for an existing library license which satisfies the following conditions:   * GPL-compatible   * Can be statically linked with closed-source programs   * Binary modifications of the library, including cases where the library is statically linked with another project, must be accompanied by the library source code Licenses which are close but not quite what I need:   * LPGL \- does not allow static linking with non-free software*   * Eclipse Public License \- not GPL-compatible due to a patent clause   * GPL linking exception \- does not require source code redistribution *: The LGPL allows static linking with some specific technical conditions - specifically, it must be possible to make modifications or use newer versions of the library, and to do that one would need to make available the object files and build scripts for the non-free components. Generally speaking, this is technically difficult and sometimes impossible (in the case of e.g. templates or inlined functions), and very often (as is my case) the underlying reasons for which static linking is required conflict with these LGPL requirements. For this reason, LGPL is unsuitable for my use case, and frankly I've yet to see a project which used static linking with an LGPL library in this manner, considering all the associated technical and legal (templates/macros/inlining) problems.


title: How to get started in coding for JBoss

text: I have an idea on how to revamp our internal application, after having accessed the needs of the users, addressing thier current issues, and the like. But I am not a coder. My last application I wrote was in college, in C, (java wasn't invented-ish!) and it was a booking system, with the option to add on other modules, blah blah. I got an A, but I became a system administrator instead, more intrested in designing and maintainend networks and infrastructure, but with the advent of virtualisation, and linux management tools such as puppet I can now manage infrastructure in my sleep! Now I want to write code - to put on my infastructure, and I want to build .... a booking system! This is just to get experience, but I am at a loss as to where to start. Setting up the environment, will take me about a day. Writing the spec, even how I want it to work, I already know, but as for actually coding in a decent manner, I can only guess. If anyone can recommend a book, website, blog, twitter person to follow, or just advice on how to build a kick butt basic jboss app, then please, "I AM READY TO LEARN" :)


title: How to avoid being sued for your software?

text: I have a written a small app as a research project that uses open source libraries. It can do packet sniffing, network scanning and man in the middle attacks on wifi and lan. This software is intended to be used for security auditing. But users can also use it to circumvent the MAC filtering of their ISP and get free internet. The case seems similar to that of uTorrent. uTorrent can be used legally, but almost everyone uses it for illegal downloading. If users download my software and use it like that, can the ISP sue me as the author of the software? What should I put into the Terms and Conditions to avoid being sued for misuse of my software? **EDIT**   I'm from Eastern Europe, but live in the UK. In which country should I ask a lawyer? People can download my software globally.


title: What are the most important points of interface between a web developer and IT?

text: Some background: My current job has be as the sole web developer for our company. I have been given responsibility for a number of external websites, as well as our internal intranet site. The external sites are currently hosted externally, and either created/maintained with a CMS, or custom designed by the external host. I will be migrating the websites to our own internal server, and redesigning them using whatever tools I deem necessary (php, jquery, MySQL, etc.). The intranet is hosted internally, but also needs a complete redesign. Our IT is currently going through some reorganization, and historically has little experience with web technology. I want to plan coordination with them, help develop proper infrastructure, and identify the primary channels of communication between us. My question is: what are the main points of coordination that normally exist between development and IT, focusing on web-based development? Given a (relatively) blank slate, what would be the ideal division of responsibilities, and primary points of direct collaboration? I know some aspects of my particular situation may be atypical (i.e. I'll be responsible for setting up the PHP environments, source control repositories, database administration, etc.), but I'd like answers to focus more on the typical configurations, as that will be more useful to others.


title: What are good approaches to cleaning up old projects?

text: I've got some software that I wrote around 2 years ago and needs some features added to it. I've realised that it's in an awful mess, and I have the urge to move everything around, tidy up, etc. I've read the Joel on Software article about not starting again, so whats the best way forward?


title: C++ Without Source Files

text: Bjarne Stroustrup mentions in his book "The C++ Programming Language, 4th Edition" that not all C++ implementations use files to store and compile code: > There are systems that do not store, compile, and present C++ programs to > the programmer as sets of files. (Chapter 15, page 419) Later in the chapter, he reiterates that certain implementations do not use files but he does not give any examples. How would such an environment function compared to a more common file-based environment?


title: Why do we need a format for binary executable files

text: When binary files (i.e. executables) are saved they usually have a format (e.g. ELF or .out) where we have a header containing pointers to where data or code is stored inside the file. But why don't we store the binary files directly in the form of sequence of machine instructions.   Why do we need to store data separately from the code?   Secondly when the assembler creates a binary file is the file is among the above formats?


title: Right design pattern to use StopWatch class

text: I have to measure execution time for a blocks of code. I had implemented simple `StopWatch` class like http://www.goldb.org/stopwatchjava.html. If I will invoke methods of `StopWatch` class directly between business logic then my source code became unreadable and unclean. What design pattern can be useful in my situation to keep code readable and clean?


title: Why should I use JAX-RS REST instead of normal servlets?

text: I'm teaching myself J2EE technologies using Glassfish as my webserver and EJB container. I'm very interested in learning REST as well, and developing an application that is adherent to the rules of REST. My first project is to write a chat client. The user will go to a webpage, download a webpage with the javascript to run the chat client (which posts the data to the server and fetches it as well). The calls to post data, and to fetch data, from the webserver will be through a RESTful interface. Right now I've done this through servlets that listen on the /chatroom/getMessages and /chatroom/postMessage URI's. The wrinkle that I run into when I try to convert this to a RESTful service using JAX-RS that doesn't use servlets is that I feel like I'm reinventing the wheel. With the servlet specification I had this HTTPSession object that made it very easy to keep track of where someone is in the chat buffer (and therefore which messages should be sent to them when they visit /chatroom/getMessages). But now when I make it completely RESTful, and just use POJOs with JAX-RS (which I actually like better from a style standpoint) I now have to reinvent session state if I want it by handing the person a token, and having them hand it back to me every time we talk just like the automagically generated session cookie would have done for me if I was using servlets. WHY should I implement this with JAX-RS and abandon the servlets? I haven't seen any JAX-RS tutorials that mix servlets and JAX-RS (probably for good reason), so this doesn't seem to be an option. What I really want to know is what compelling reasons there are for going with REST. What does it buy me to not just use the servlets in a RESTful way?


title: In an MVC system, where should the database persistence code sit?

text: I've seen multiple configurations for persisting information to the database. Generally, three types of designs seem common in my corner of the world:   * Controller manages the persistence    * Model manages the persistence   * Third party library manages the persistence, usually requiring some sort of annotations on the model. I'm wondering which configuration (if any) is, conceptually, the easiest to use/most compatible with an MVC architecture? (If it's not one I listed, please give a quick outline/overview as part of the answer)


title: Find feature in NetBeans (or even Eclipse, or others) excluding comments

text: Is it possible to use the find feauture in NetBeans or other Java IDE excluding commented code from the results? How?? Given a project I'd like to find all the occurrences of a word without getting back possible matches that come from code that is commented. Am I the only one that needs something like this?


title: Should MVVM ViewModel inject an HTML template for default view?

text: I'm working on web application design that includes Knockout.js and have an overall MVVM question: Does it make sense for the ViewModel to automatically inject a default HTML template (pulled from separate file)? More detail: suppose I have a site like this...               header...         widget 1         widget 2         widget 3     footer      ...and widgets 1/2/3 are going to be Knockout.js ViewModels **determined at runtime** from an overall list of available widgets, each with associated HTML template file. I understand that in MVVM you want the view (HTML template in this case) to be separate from the ViewModel (Javascript file in this case) so that people can edit it separately and possibly provide multiple templates for different "skins". However, it seems like it would also make sense for the ViewModel to point to a **default** html template that gets automatically used unless the controlling code provides a different one. Am I looking at this correctly? As an example, see this answer on StackOverflow where he recommends injecting the HTML and then the ViewModel. Seems like a one-liner would make more sense in that case, with the possibility of overriding a default template value.


title: Is CType() ever the preferred option?

text: Is there any time `CType()` is the proper option over other methods? I did plenty of thinking on this myself, but wanted to put the question in hopes there would be answer to my question so I can put the question to rest in my workplace. My idea is that `CType()` should never be used. But others seem to think it's still around for something other than backward-compatibility. So is there still a use for it? A big problem is that many people don't seem to understand the difference between Casting and Converting. ## Converting Vs Casting This was one such line of code:               With objZipFile.GetEnumerator()         While .MoveNext             objZipEntry = CType(.Current, ZipEntry)             … all this work is done with the objZipEntry         End While     End With      If my buddy ever reads this, he'll be like, "MY CODE!!!!" lol. Yes, this is your code. And as I discussed with him, .Current is an enumeration of objZipFile, but its type is ZipEntry. So why is he "Converting" with `CType()`, when what he's really doing here is Casting. He should be using `DirectCast(.Current, ZipEntry)`. So the proper way to Cast something is to use `DirectCast()`. But this isn't a discussion about `DirectCast()`. The point here is that `CType()` Should certainly not be used to Cast, it's a Conversion tool, so let's talk more about Converting. ## To CType() or Not To CType(), I don't think so In the simplistic example, I have a string `"123"`, and I want the string to be converted to an Integer. So many times, you see something like this:               Dim result as Integer = 0     result = CType("123", Integer)      Great! It Works! Then what is the difference between that and this:               Dim result as Integer = 0     result = Integer.Parse("123")      Well, with that exact example, the difference is that `CType()` took more resources to run. If I gave you two clear drinks and told you one had a health rating of 10, and the other of 9. You don't choose the 9 on principle that it isn't that much less healthy, you choose the dam 10. Also, the `Integer.Parse` line is a couple characters of less typing. Okay, but what if your input isn't "123"? What if the input is "UrMom"? I hear `CType()` won't break... but as far as I know, that isn't true. `CType()` breaks just as much as `Type.Parse()`. I'd like some arguments on that. Though an argument supporting `CType()`'s resilience alone isn't reason enough to use `CType()`. On the other hand, we have this option in the `Type`-Class:               Dim MyInt As Integer = 0     Dim TryInt As Integer = 0     If Integer.TryParse("54", TryInt) Then         MyInt = TryInt      Else         'Handle it appropriately      End If      Not only are we parsing the data, but if it doesn't parse, we are handling it correctly. Which is a much better option that throwing a `Try/Catch` around bad code and letting it break before handling its failure in the `Catch/Finally`. Keep in mind, there may be multiple different ways to cast and convert, but the main purpose of this question is to prove or disprove that `CType()` simply shouldn't be used. My main argument is this... The only arguments I've seen that support the use of `CType()` are those that say `CType()` won't break if passed bad data, or that `CType()` is better if you are unsure of the data going in. In response to that I say Pish-Posh. Rethink your code, place conditionals, and know what you're wanting to use the item for. If something happens that you weren't expecting, handle it correctly. So is there any time `CType()` is the proper option over other methods? Please provide examples.


title: Partial GPL 2 legacy code into a GPL 3 project

text: I plan to import works from a Java GPL2 project into a GPL3 one.   1. How must I "head" all my project derivating sources files : must I put the GPL2 license of the original project (saying that "This file is part of PROJECT_NAME ...") above my project one ?   2. How should be the LICENSING file of the whole projet : must I put both licenses in it ?   3. I don't know yet if I will import nearly complete classes or just some pieces of codes from the original project. Anyway, how should I inform the user (saying, in a about dialog) : is saying "Work derivated from PROJECT_NAME project" enough ? Thanks in advance.


title: Fun resources for learning Java

text: Is there a fun way to learn Java? Instead of what's the "best" way to learn it, I'm wondering the funnest way to learn it. I'm taking an introductory course on programming right now to see what it's all about, but quite frankly it's not very enjoyable. I certainly love programming in an applicable sense (for accomplishing layout and analytics tasks), I find that it takes a while to get to the point (it took me a year with JavaScript) to feel like you can just dream things up and try them out. I realize the subjectivity of the questions avails it to flames, etc., so I'll restate the spirity of the question. I want to know what resources/methods people have employed to make learning a programming language more enjoyable.


title: Entity Framework designer not effective anymore

text: At my current workplace, **Entity Framework 5** is used for all data access/manipulation. It is a database-first approach using the model designer to add/edit/delete/update entities. **Problem** We now have tons of tables and this is becoming a nightmare to update. The model is very convoluted and it can sometimes crash the IDE. I'm not super clued up on the Entity Framework side of things, but surely this isn't the recommended approach. I have never liked the designer from the beginning. WYSIWYG-like designers spell trouble in my eyes. **Solution?** Structural changes to the database are essentially done by DBAdmins so we can't do code-first (anyway, I prefer not to have database tables generated). Is there a better approach to this? Shouldn't we be using an XML-based mapper instead of using the designer. What about code-first to the existing database?


title: Is there a de facto standard documentor for Javascript?

text: I'm trying to document my code using JSDOC3, that has a similar syntax to PHPDocumentator / Apigen. But is there a de-facto standard for Javascript inline documentation? I think Google Closure is the most complete (or so it seems), but what is widely adopted by IDEs and what most people expect to the docs to be?


title: Passing configuration to a handler

text: I'm building my own JET Parser and one of the things I am trying to do as per the JET specifications is to allow changing of the start and end tags from the default `<%` and `%>`. Right now I have a parser handler modeled after `javax.xml.parsers.SAXParser` and `org.xml.sax.ext.DefaultHandler2`. The handler can take handle a directive that will change the parser configuration. So I am thinking of the following options:   * have a `setParser(Parser)` method that gets called by the handler and have that as part of the interface. The method is called by the Parser when starting the parse process.   * have a `directive(..., Parser )` method that gets called by the handler and have that as part of the interface. This limits the parser updates to directives only.   * store the startTag and endTag in the handler and have the get methods.   * have a new configuration class that gets passed around using the set or directive method. My current thinking is to have a `directive(..., ParserConfiguration )` method that gets called by the handler and have that as part of the interface. This limits the parser updates to directives only and only let it deal with configuration. Is the approach I have chosen is a good option for an API, or is there a better alternative that I didn't think of yet?


title: Is the "Objects First" approach a good idea?

text: Do you think programming novices should learn objects from day 1, as seen in the book "Objects First With Java: A Practical Introduction Using BlueJ" by David Barnes? Or do you think this is a bad idea? For those unfamiliar with the book, here is a list of the topics discussed in the chapters: > Chapter 1 deals with the most fundamental concepts of object-orientation: > objects, classes and methods. It gives a solid, hands-on introduction to > these concepts without going into the details of Java syntax. It also gives > a first look at some source code. We do this by using an example of > graphical shapes which can be interactively drawn, and a second example of a > simple laboratory class enrolment system. > > Chapter 2 opens up class definitions and investigates how Java source code > is written to create behavior of objects. We discuss how to define fields > and implement methods. Here, we also introduce the first types of > statements. The main example is an implementation of a ticket machine. We > also look back to the laboratory class example from chapter 1 to investigate > that a bit further. > > Chapter 3 then enlarges the picture to discuss interaction of multiple > objects. We see how objects can collaborate by invoking each other's methods > to perform a common task. We also discuss how one object can create other > objects. A digital alarm clock display is discussed that uses two number > display objects to show hours and minutes. As a second major example, we > examine a simulation of an email system in which messages can be sent > between mail clients. > > In Chapter 4, we continue by building more extensive structures of objects. > Most importantly, we start using collections of objects. We implement an > electronic notebook and an auction system to introduce collections. At the > same time, we discuss iterations over collection and have a first look at > loops. The first collection being used is an ArrayList. In the second half > of the chapter we introduce arrays as a special form of a collection, and > the for loop as another form of a loop. We discuss an implementation of a > web log analyzer as an example for array use. > > Chapter 5 deals with libraries and interfaces. We introduce the Java > standard library and discuss some important library classes. More > importantly, we explain how to read and understand the library > documentation. The importance of writing documentation in software > development projects is discussed, and we end by practicing how to write > suitable documentation for our own classes. Random, Set and Map are examples > of classes that we encounter in this chapter. We implement an Eliza-like > dialogue system and a graphical simulation of a bouncing ball to apply these > classes. > > Chapter 6, titled Well-behaved objects, deals with a whole group of issues > connected to producing correct, understandable, and maintainable classes. It > covers issues ranging from writing clear, understandable code - including > style and commenting - to testing and debugging. Test strategies are > introduced and a number of debugging methods are discussed in detail. We use > an example of a diary for appointment scheduling and an implementation of an > electronic calculator to discuss these topics. > > In Chapter 7, we discuss more formally the issues of dividing a problem > domain into classes for implementation. We introduce issues of designing > classes well, including concepts such as responsibility-driven design, > coupling, cohesion, and refactoring. An interactive, text-based, adventure > game (World of Zuul) is used for this discussion. We go through several > iterations of improving the internal class structure of the game and > extending its functionality, and end with a long list of proposals for > extensions that may be done as student projects. > > Chapters 8 and 9 introduce inheritance and polymorphism with many of the > related detailed issues. We discuss a simple database of CDs and videos to > illustrate the concepts. Issues of code inheritance, subtyping, polymorphic > method calls and overriding are discussed in detail. > > In Chapter 10 we implement a predator/prey simulation. This serves to > discuss additional abstraction mechanisms based on inheritance, namely > interfaces and abstract classes. > > Chapter 11 introduces two new examples: an image viewer and a sound player. > Both examples serve to discuss how to build graphical user interfaces > (GUIs). > > Chapter 12 then picks up the difficult issue of how to deal with errors. > Several possible problems and solutions are discussed, and Java's exception > handling mechanism is discussed in detail. We extend and improve an address > book application to illustrate the concepts. > > Chapter 13 steps back to discuss in more detail the next level of > abstraction: how to structure a vaguely described problem into classes and > methods. In previous chapters we have assumed that large parts of the > application structure already exist, and we have made improvements. Now it > is time to discuss how we can get started from a clean slate. This involves > detailed discussion of what the classes should be that implement our > application, how they interact, and how responsibilities should be > distributed. We use class-responsibilities-collaborators (CRC) cards to > approach this problem, while designing a cinema booking system. > > In Chapter 14, we try to bring everything together and integrate many topics > from the previous chapters of the book. It is a complete case study, > starting with the application design, through design of the class > interfaces, down to discussing many important functional and non-functional > characteristics and implementation details. Topics discussed in earlier > chapters (such as reliability, data structures, class design, testing, > extendibility, etc.) are applied again in a new context.


title: File shredder algorithm

text: As a part of learning system programming, I am looking to implement a file shredder. The simplest way (and probably seen as naive) would be to replace the data bytes with zeroes (I know OS splits the files and I'll replace bytes in all those chunks). But when I google on this topic, I am surprised to find multiple pass algorithms, some going as high as 35! Could someone elucidate the benefit of multiple pass please? I couldn't find any explanation. Thanks


title: Is there an equivalent of mod_rewrite for Twisted web?

text: I've been programming in PHP for a long time, and I've just recently decided to make the switch to Python. Of all the Python web frameworks, I settled on Twisted Web to build the framework of my startup. However (and I know it sounds nitpicky), mod_rewrite was something that I really appreciated about Apache. I want the entire system written in Python, and not just bits and pieces written in PHP and Python: while a PHP frontend could work, I'd avoid it if it was at all possible. Is it possible to build such an application without resorting to ugly urls? Note: I am aware of the fact that Django allows URL rewriting, but it kinda defeats the purpose of using Twisted by itself.


title: Any recommendations for setup/teardown of browser automation testing?

text: I have been doing some browser automation testing recently using Selenium (and Watin a bit too) and have reached a point where I am looking for recommendations on controlling the environment I'm testing. For example, if I have a test that registers a new user on site (or similar database dependent task); how do people ensure that the test does not persist or at least is able to be repeated without always changing the test itself? I'm seeking recommendations for ensuring my integration/acceptance tests using Selenium can be ran without having to worry about changing them or the environment manually.


title: Am I using Factory and Impl classes properly?

text: In my 2d destruction derby simulator I have a CargoTruck class and CargoTruckImpl that implement an interface called Truck. CargoTruck has a reference to CargoTruckImpl which is returned through the CargoTruckImplFactory. But then I decided to add to this chain by having CargoTruckImpl and CargoTruckMovementImpl use the interface called Movement. CargoTruckImpl has a reference to CargoTruckMovementImpl which is returned back to CargoTruck through the MovementImplFactory. CargoTruck->CargoTruckImpl->CargoTruckMovmentImpl FuelTruck->FuelTruckImpl->FuelTruckMovmentImpl Is adding to the chain like this bad? Am I violating the Separation Principle or the Open-Closed Principle by using Factory classes this way? Is there a better way of doing this?


title: What kind of users stories should be written in the initial stages of a project?

text: When just starting a project, you have nothing---no UI, no data layer, nothing in between. Thus, a single story like "users should be able to view their foos" will entail a lot of work. Once you have that story, one like "users should be able to edit their foos" is more realistic, but that first story will involve setting up a UI layer, a presentation logic layer, a domain logic layer, and a data access layer. This doesn't fit with my concept of "tasks": to me, I'd rather have something like the following "tasks":   * Show dummy data for a user's foos in HTML, derived from JavaScript objects.   * Set up a presentation logic layer, and connect the JavaScript objects to it.   * Set up a domain logic layer, and connect the presentation logic layer to it.   * Set up a data access layer, and connection the domain logic layer to it. Do all of these fall under the single "story" above? If so, I feel like stories are not a terribly useful framework in the early stages of a project. If so, that's fine---I just want to make sure I'm not missing something, since I'm really trying to learn this agile methodology as best I can.


title: Switch form paragraph mode to line break mode in WYSIWYG editor because of client request?

text: I'm building a website fro a client which uses TinyMCE as the main WYSIWYG editor. Now my client asked if it is possible to write a line and make a line break and then continue without leaving a space between the text before and after the line break (e.g. just like in word). I told him that the web uses paragraph for formatting and not line breaks. Still he'd like to use line breaks for formatting. Should I convince him not to use line breaks for formatting or should I just switch TinyMCE to line break mode (which the is not recommended in the TinyMCE documentation).


title: Is OpenGL after C++ job oriented?

text: First, my regards to all programmers out there who have put their endless efforts in learning and becoming expert, wise, efficient and best. Let me describe my situation. I have just graduated from Electronics and Communication Stream. Though I have more interest in software development and hence I have opted to become a software developer rather than Electronics engg.   1. I have learned C++ and wish to wish to go more deep.   2. I have started to learn OpenGL. Guide me in the following:   1. Is OpenGL good to learn and is it job oriented?   2. Should I learn some other language rather then OpenGL after C++?


title: How to ask the boss to pay for qualifications?

text: I'm working as a junior developer for a startup company, and have been working here around 7 months now. After 4 months, we had a late quarterly review, and just before the boss mentioned there was a training budget, and we should let them know what training we needed and they'd get it for us. I asked for some training at the time, but 3 months have passed without mention of it, and I have since learnt what I needed in my own time (I just can't stop learning new things!) I took on a new role recently, so have been given some cheap ($60) training for that however. Now the next review is approaching, and I would like to get Adobe Qualified Expert qualifications for ActionScript 3 / Flex. I was told by a contracted co-worker who had left that I should try to get the company to pay for this, as it's something they can tell potential investors as a selling point. My question is though; how do I approach this with my boss? I don't want it to sound like I'm looking for another job and want the qualifications to look elsewhere! Edit: I should mention the company I work for is very qualification-light at the moment, and all the flex developers are junior level at the moment. I'm looking to progress which is why I want the qualifications. Even if I can't get them through the company then I'll be learning it myself, but would rather not stump my own cash when it's to help the company in the long run!


title: Looking for jobs after a project ending badly

text: My company just canceled the project I was working on because they were dissatisfied with how it was going. I was quite disappointed with it because I thought the project was going well and I had already explained the limitations that the software would have due to the time constraints. I have decided that I will now look for a new job, but I am worried the project ending badly may give me some difficulties. Any advice on how I can minimise the difficulties this causes me without being dishonest?


title: Is it fair to ask a team to start using CoffeeScript?

text: I started my new job as a JS developer in November and starting implementing Backbone pretty soon after. This was a big enough learning curve for the team (me included), however I'm thinking about looking at CoffeeScript, which I'm guessing would require everyone on the team to know it? Is that too big of an ask, just to make me slightly more productive?


title: Is this Observer variant an improvement?

text: In a C++ code base I've been working on, they have a bunch of instances of the observer pattern, but it's a little different from the classical pattern. In the classic, the Observer is a specific interface with specific method(s) that are called when the Observable changes or has new data.               Observable                       Observer     register( Observer* )            update( data1, data2 ... )      In our code base, we use a template class that takes the number and type of arguments to the update() method as parameters, and allows you to specify any pointer-to-method as the recipient of the data.               Observable                               register( Functor<data1, data2> )         Is this an improvement over the original pattern? Here's what I think are the pros of each approach: Classic:   * clarity - the interface marks which classes are recipients of observable data    * less code - the boiler plate and ugly template syntax to create the functor are somewhat onerous Variant:   * flexibility - I can make any object in my system receive the update (if it has the right method signature) without having to change the original object As a another option, do I have it all wrong that this is the Observer pattern in practice?


title: Should a developer argue against unnecessary or harmful features?

text: What is a good attitude from developers when discussing new features, and namely, non critical/questionable features? Say you are developing some sort of Java like language, and the boss says: "We need pointers so that developers could fiddle with object memory directly!" Should the developer shoot down the idea because it adds unimaginable complexity and security vulnerabilities, or should he do what's asked? This may not be a good example, but what about things that are more in a gray area, like adding buttons that break workflow, or goes against internal structure of the program, etc.? What is the optimal "can do" vs. "can't do" distribution for a regular programmer? EDIT: The question is not about a bad boss :D I was more interested how do people approach new problems that add a noticeable amount of problems while maybe being marginally useful. Should the general attitude be:   1. yes we'll do it, screw the complexity   2. maybe   3. no, the general rework, and implications don't justify the change What should be the reaction of a good developer?


title: How should we implement Scrum with two projects for one team?

text: I'm starting at this new company as a scrum master, and they want to dive into Scrum, which is nice and all, but they only have enough people (4) for one team. The road map includes delivering a new product and maintaining the old one, so what should we do?   * 2 products backlogs for 1 team? How should we do planning in this case?   * 1 product backlog for 2 products? How will sprint review work in this case?


title: Is there any merit to using `union` to create an alias?

text: I've inherited a bit of code and saw something new. They have a data structure definition out in a .h file, and in various local files they'll declare:               union globalStructOstuff localVar;      **Is there any merit to this?** I could see some if the global was some placeholder and the local versions were going to be different eventually. But that's not the case here. So I think all it's doing is causing new guys a couple of extra minutes searching for definitions. I'd axe it once I got the chance, but I wanted to see if I'm missing some greater purpose. **Edit, resolution**   With your fine help, I managed to open my eyes and realize globalStructOstuff isn't a struct at all, it's a union which holds the struct of a similar name. And they didn't use typedef. So all that's happening here is declaring a local variable. It has a type of union. No alias to anything global. Sorry for the confusion, thanks for all your help.


title: How do you determine a 'release' date when a team uses Scrum

text: I'm new to scrum and using it on a project. We do 3 week iterations, estimate at the beginning and then collect the points at the end. We have a product back log (probably not complete). If you do estimates of the entire back log at the beginning aren't those estimate just 'wild ass guesses' So when do you estimate the back log and how do you determine a release date? ep


title: Why aren't postfix and primary expressions symmetrical?

text: Every primary expression is a postfix expression but a postfix expression is not primary expression. But in mathematics, equality seems to be symmetrical. That is: > If _A_ is _B_ , then _B_ is _A_ Why isn't this the case for postfix and primary expressions?


title: Is my concept in open source license correct?

text: I would like to justify whether my concept in the open source license is correct, as you know that, misunderstanding the terms may lead to a serious law sue. > The main difference among the open source license is whether the license is > copyleft. Copyleft license means allow the others to reproduce, modify and > distribute the products but the released product is bound by the same > licensing restriction. That means they have to use the same license for the > modified version. Also, the copyleft license require all the released > modified version to be free software. > > On the other hand, if any others create derived work incorporating non- > copyleft licensed code, they can choose any license for the code. The several kinds of license and comparison > GPL is a restrictive license. Software requires to released as GPL license > if that integrate or is modified from the other GPL license software . The > library used in developing GPL license software are also restricted to GPL > and LGPL , proprietary software are not allowed to employ (or complied with) > in any part of the GPL application. > > LGPL is similar to GPL , but was more permissive with regarding allow the > using of other non-GPL software. > > BSD is relatively simple license, it allow developer to do anything on the > original source code . The license holder do not hold any legal > responsibilities for their released product. > > Apache license is evolved from the BSD license. The legal terms are improved > and are written by legal professionals in a more modern way. It covers > comprehensive intellectual property ownership and liability issues. Also, are there any popular license beside these?


title: choosing Database and Its Design for Rails

text: I am having a difficulty in deciding the database & its structure. Let us say the problem is like this. For my product I have various customers( each is an educational institute) Each customer have their own sub-clients ( Institution have students) Each student record will have some basic information like "name" & "Number" . There are also additional information that a customer(institution) might want to ask sub-client(student) like "email" or "semester" I have come up with two solutions : 1\. Mysql _**__insititution_ ___** id-|- Description| * * * _**___Student__** id-|-instituition_id-|-Name-|-Number| * * * _ **_student_additional_details_ ___** student_id -|- field_name -|- Value * * * Student_additional_details will have multiple records for each student depending upon number of questions asked from institution. 2.MongoDb _**__insititution___** id-|- Description| * * * _**__Student_ ___** id-|-instituition_id-|-Name-|-Number|-otherfield1 -|- otherfield2 * * * with mongo the structure itself can be dynamic so student table seems really good in mongo . But the problem comes when I have to relate student with institution . So which one is a better design ? Or some other idea ?


title: What is the best method for releasing free "extension" or example code based on a closed source proprietary project?

text: I have a proprietary project. It's a simple authentication library. I want to write open source(BSD) extension/examples for it. These examples interface code, connecting my authentication library to a database containing users. I'm providing examples which people hardly ever use out of the box, but are excellent starting points for tying it into their own database. I want to be able to release these extensions separately from the library. What is the best way of to this? My idea is to use a free github project and put the extensions there as well as the demo version of my authentication library(ie, just the assembly). How would I manage different versions of the authentication library though? At the moment, I use SVN for managing the source code of the authentication library, though I like git as well, so would switch if that'd be better. Does anyone know of a good way of managing this kind of thing?


title: Variables initialization and for loops in a flowchart

text: I have to create a flowchart to a C# programm and I am not very familiar with it. My problem is that I do not know if one should represent variables initialization in a flowchart and if so how should I do it. Second problem is that I am not sure about the correctness of my for loop. Here is the flowchart I created tot a part of the programm. It would be very nice if you can tell me if that is correct and if not what should I correct. Thank you! ![enter image description here](http://i.stack.imgur.com/Hey0G.png)


title: Do I have to remove my app from app store? (Copyright infringement)

text: I just got an copyright infringement notice that says my app infringes on the usage policies of the services my app uses. However, this mail does not come directly from the company that runs the website I pull information from. The mail comes from a company that has some paid apps in the same category on the app store (mine is free), so they obviously want me gone. My question is, can I just ignore this mail until I hear directly from the company that runs the website? Judging from their (the company that contacted me) website, they have no connection what so ever to the company that I fetch information from.


title: Java API Deprecations

text: Who decides the API deprecations the JEE specification or the vendor of JDK like Sun, IBM?


title: Should I put utility methods inside a class?

text: I have been working on a library which contains a large set of functions. For the sake of simplicity, I am going to use just one set as an example. I am not sure which is the better way, in terms of ease of use and performance, whether I should put those methods provided as individual methods, prepended with the function category, or whether it is better to create a Class containing all the method as static methods. For Example: Individual methods: (p.s. this could also be writen without `request_` in the function name and using Namespaces instead)               function request_method() { ... }     function request_url() { ... }     function request_useragent() { ... }     ....      Classed method:               class Request {         public static function method() { ... }         public static function url() { ... }         public static function useragent() { ... }         ...     }


title: Implementing Scheduling Within an Application

text: I'm building an app and the end user will be using an Admin screen to schedule content on the front page. They will be choosing two dates, a start date and an end date. Obviously I don't want to cycle through the entire collection to see if todays date is between any of the start or end dates every time the front page loads. Also, don't want the user to be able to schedule two things that overlap each other. There should be a better way than checking for conflicts with each record before saving. Using Node/Socketio/Express/Mongoose I could index the collection in Mongo then sort accordingly to test for today's date and make sure there aren't conflicting schedules. Also, I could have a flag that is set once the day changes that signifies current content. I thought there might be a better way. Does anyone have any thoughts?


title: Frustration with Java Swing layout managers

text: I have been trying for years to master Swing layout managers with no success. Every time I need to do something with Swing, it is like pulling nails to get the visual components to line up the way I want them to. I am familiar with frameworks like Matisse but that's not the point. My question is: Why does Swing even need layout managers? It seems like an overcomlicated paradigm. What I would like to be able to do is jave a simple JFrame and then for each component (like JLabel) simply specify X and Y coordinates where I want it to be situated -- done deal. Can anybody explain what is wrong with this simple approach that would work predictably 100% of times? Or is there an actual layout manager that does things exactly like this?


title: In JSF where do objects like PhaseListeners fit in the MVC pattern?

text: When it comes to JSF, I've had trouble distinguishing where certain objects I create fit into the overall MVC pattern. The View is simple enough since that's handled by the .xhtml template but when it comes to objects like:   * Action/Change Listeners   * PhaseListeners   * Validators   * Navigation Beans   * Converters   * Filters At first I'd assume some of these belong to the Controller but I've seen a number of statements here and elsewhere on the web stating that for most developers using an MVC framework, specifically JSF, the majority/entirety of the Controller is already implemented by the framework. The following Q&A: Understanding JSF as a MVC framework , while very informative still leaves me feeling pretty vague on the matter. The accepted answer states that consumers of JSF do not implement Controllers while the thesis linked to at the bottom of the answer clearly states that Listeners are a part of the Controller pattern.


title: Should I use Legitimate Email spoofing?

text: Recently I receive a request: users' emails are stored in the database, and as request of a user, the system will send an email on their behalves. To add more context, it's like sending an email from the vendor, to their customers' email addresses. But it's not a fixed email (it depends on which vendor ask the system). Using JavaMail, I can simply set the `from` field. But something doesn't seem right. When searching for this kind of work, I come across "Email spoofing" - which looks like what I'm going to do. There are some drawbacks for this approach, such as it may make the emails attractive to the spam filters, and so on... Ofcourse I can just do as the client want, but I just wonder, is there any better alternative?


title: Sequence diagrams and the Implementation

text: In the design phase we create UML Sequence diagrams (in OOD). My understanding is that after creating an Use Case diagram if we need to show further information in terms of time sequence of events of that Use Case, we can go for sequence diagrams. My question is, should a sequence diagram represent exact implementation details? If I ask in another way, should all method calls and object interactions in the implementation be shown in the Sequence Diagram? Or else it should present a high level picture of the implementation? Normally in the implementation, things could be implemented with slight differences than specified in design diagrams. So that if a sequence diagram should show exact implementation details, we might have to revise them after the implementation. Another related question would be, who are the audiences of these sequence diagrams other than the author? An answer for this question might answer the original question as well.


title: What's the best way for me to get started using version control in an opensource project?

text: It was suggested that I take my project open source due to its size and my lack of skills, so I checked out Google Code, and started making a project and now it's asking me if I want the project to have Git, Mercurial, or Subversion code hosting. I don't even know what code hosting is, and a search just confused me more with the debates between all these things, and this is made even worse as Google Code is asking me which type of license I want. I think I'm not quite understanding what open source really means, can someone pretty much make a quick layman's cheat sheet on what all this is? Much appreciated. **Edit** There have been a lot of great responses on these three versions of code hosting, but I think I failed to communicate the real question: Basically I've no idea how this open source stuff works, why would I host the code somewhere like this? And would that mean I have to take the site off of my current hosting, or is this an entirely different type of hosting? What happens when I make my site open source, what rights do I have, what rights do I give away. How does it work, do people just come and throw code at me for free? Perhaps these are stupid questions, and if that's the case then I guess I need stupid answers, I seriously have no idea what open source is, except for the concept of sharing code...


title: Is short-circuit evaluation a consequence of call-by-name?

text: If the boolean operators &&, || are implemented as infix methods, then isn't short-circuit evaluation just a consequence of being implemented using call- by-name semantics, since, for example, the && method wouldn't then evaluate the second arg in any case if the first is false. I'm just wondering because they are generally treated as separate topics (e.g in the Scala intro course I'm taking - https://class.coursera.org/progfun-003/lecture/5 ) but short-circuit evaluation seems to just be a consequence of call-by-name.


title: Use MAC address for license

text: One of my company product need to implement a license mechanism. I'm planing to generate a key base on users PC MAC address. But I'm bit scared is this method confuse with some advance hardware. configurations such as.   * Multiple network cards.   * Virtualization.   * Mac address change possibilities(?)   * Working with VPNs. Is it a good idea to generate license key with MAC address? Some ideas?


title: Unit (regression) testing scientific algorithms given floating point behavior

text: I have been working on a project and running into a very difficult problem. The problem can be stated simply as how to unit-test numerical algorithms. However if you just took this simple statement you would get the standard set of answer isolation of input, random processes, mocking, tolerancing, etc.   The answer (if there is one) does not reside with these. Also, as a note, I am not concerned with testing the correctness of the algorithm. That is done with very different methods and it is assumed that the algorithm is correct. What I am using unit-testing for is to make sure that changes in other parts of the system/support algorithms do not change the output of the algorithm under test. So, for a description of the problem: We have an algorithm which takes Gigabits of data, processing it, and generates an image with a corresponding map of which pixels are good and which ones are not. It is this map which I need to verify does not change and pixels which are not valid are not to be used in any way other than the fact that they invalid. If this was all that was given I would have many possible solutions and in fact the method have been using for years is to look at the number of valid pixels, the average, standard deviation, peak and valley of the image. This has proven very sensitive detector for changes. But, this year has added complications which is causing issues with this approach.   * The number of threads being used has increased causing changes in the floating point behavior. In the past the smaller number of thread was accounted for in the tolerances used.   * We have been using floating point (as compared to double) to increase throughput. This has caused the rounding behavior to change even more and combined with the number of threads makes it worse. This has also been made worse as we move to using SIMD processing like GPU and/or AVX instructions sets.   * We have been enhancing the algorithms used to recover more of the pixels which would have been marked as invalid in the past are not valid. This combined with 1 and 2 above is resulting in some pixels being included on some machine and not on others. Since these are on the edge of useability these difference are handled by the algorithms with use this image and are not of concern for the system as a whole, but are causing problems with unit testing the algorithms.   * We have also recently ran into the problem that two numbers (internal to the calculation) are the same and because of the rounding behavior one or the other is picked resulting in different outputs. . Again this is not a problem of the system as a whole, only with unit testing to flag for differences.   * As a minor side example, we also have other non-linear algorithms with due to rounding behavior can give different outputs. Since these algorithms are self correcting the final solution is good, but has a higher variability than easily accounted for unless the tolerances are opened larger than desired. So, my questions is how to account for these issue in unit testing.   I strongly need unit testing because we have a team of programmers working on the system and we need the ability to detect when someone makes a change which unknowingly impacts other algorithms. Yes this has happened in the past and the method being used at the time caught the change before it reached the final product. As the primary algorithm developer I can use your help. I have had many ideas, but they don’t work for all cases and it’s not clear when to use one of the different methods. **Edit:** I now that this is frequently called regression testing but I also know that many time it is also generically called unit testing by many people, even if it's not completely correct. I am not necessarily looking for a magic bullet (that would be nice) but I do need a way of handling these issues in a way which can be handled by others in the group which may not be as knowledgeable on the details. If that is a “pick” one of these methods that is fine if it the rule are clear. We do adjust the parameters when we change the algorithms, but once it is fixed the floating point behavior is still causing differences. When we see differences we always investigate why and in general we try to adjust the algorithm to reduce the difference, but there are times where these is not possible because of the additional computation time. If we stayed away from the limits this would not be an issue (as in the past) but to advance the technology we need to push the limits giving rise to the issues described. You can see this in a simple example. Calculating an average of many numbers. If you stay with number which are close to each other, there are simple methods to make sure the results are accurate. Now when you allow for numbers which have large (orders of mag) difference, with threading, float compared to double, etc you can get very different results. Yes I know there are algorithms which can be used to fix these issue but they can be very computation expensive. While averaging is not my problem you could imagine that the difference don’t impact downstream processing but you still want to write a test to monitor the calculation.


title: What is the best and most cost affordable solution for storing user uploaded videos and pictures?

text: I'm in the process of building an iOS application that will allow users to upload short videos (low res. and < 5 seconds) as well as full-size images as taken by their iOS device. Not being certain of how successful this endeavor will be I'm looking for something solid, cost affordable and can scale as (if) needed. Here are my requirements in a nutshell:   1. Users will be able to upload low res. vides < 5 sec. in length or full-sized images captured from their iOS device.   2. I need the ability to monitor the amount of storage used on a user-by-user basis for billing and even restricting further uploads if, for example, they have reached a certain threshold   3. I need something robust but cost effective (I'm a one man operation at this point). Something that can grow and scale with me would be ideal. Any help in reaching this goal is definitely appreciated. Thanks -wg


title: Need some advice on CLI design, I need to provide simple but powerful command line options

text: I am writing a utility that runs on RHEL5 command line. I need my command line options to be simple but powerful. I looked at the various UNIX utilities to get an idea of how simple command line utilities have to be. Do you guys suggest any documents/links that talk about command line etiquette? I am modelling my utility on top of LVM (that's all the info I can give for now). I know it's a software engineering question, but I thought it would be appropriate to post here. Please advise.... PS: I am not asking for details about getopt or command line utility parsers.....


title: Backing up messages in S3 within a Storm topology

text: In my project we are trying to build up a KIND-of-a-lambda storm based architecture. The component would be responsible for indexing the site usage events so we expect a quite massive random load. The solution for real-time processing of the messages seems fine, but in parallel to the "speed layer" we want to back up the messages in a raw form (just as they are coming down from the queue) in Amazon S3. Since writing a file per message is obviously out of the question, we need to somehow buffer/aggregate the messages before posting to S3 - and here is where the problems begin. We have two concurrent approaches and none seems perfect:   1. We used Redis as a buffer. Basically messages coming down from a queue (RabbitMQ) are buffered in Redis and once some preconfigured batch size (say 1000) is reached the buffer is flushed and stored to S3. The whole message proccesing cycle is not transactional. Once message is stored to Redis it is acknowledged in the queue. This means that if Redis dies the whole batch gets lost and this is not acceptable. We can think of Redis cluster to make the thing more bullet proof but... doesn't it seem like going in a wrong direction?   2. The second approach would be to use Trident Topology. Changing the input queue to Kafka makes things looking more or less straightforward. The message processing cycle can be transactional. HOWEVER, there is this one annoying keyword that keeps beeing repeated in the Trident documentation - **small batches** \- that Trident assumes small batches. For example the TransactionalTridentKafkaSpout batches the messages into 2 seconds chunks. This is much too little for us. I'm not sure why the batches should be small, but if it's really required maybe the first approach is better? Which one from above is better? Maybe somoeone would come up with a "third" idea?


title: How would I develop an avatar based 3D conference environment?

text: I want to develop a 3d environment to be used for meetings and other such functions. Each attendee could log in with a customized avatar and could collaborate and discuss via voice and text chat. I would like to add in multimedia content features as well into the environment. I need help regarding platform selection preferably I want to implement it as a web application with no local installation. I'd like to avoid a browser plug-in unless absolutely necessary. I don't know graphics programming so I'd prefer an approach that uses existing platforms and off the shelf software. I have considered the following options thus far:   * WebGL   * Google O3d   * web 3d's X3D    * VRML   * X3doom   * Sirikata Platform    * yogurt3d   * Unity3d   * Jibe   * OpenSim   * Papervision3d   * Flash   * 3dmlw   * Java3d   * Infinity3d   * Cube3   * CloudMach Are there other possibilities?


title: Programming concepts taken from the arts and humanities

text: After reading Paul Graham's essay Hackers and Painters and Joel Spolsky's Advice for Computer Science College Students, I think I've finally gotten it through my thick skull that I should not be loath to work hard in academic courses that aren't "programming" or "computer science" courses. To quote the former: > I've found that the best sources of ideas are not the other fields that have > the word "computer" in their names, but the other fields inhabited by > makers. Painting has been a much richer source of ideas than the theory of > computation. > > -- Paul Graham, "Hackers and Painters" There are certainly other, much stronger reasons to work hard in the "boring" classes. However, it'd also be neat to know that these classes may someday inspire me in programming. My question is: what are some specific examples where ideas from literature, art, humanities, philosophy, and other fields made their way into programming? In particular, ideas that weren't obviously applied the way they were meant to (like most math and domain-specific knowledge), but instead gave utterance or inspiration to a program's design and choice of names. **Good examples:**   * The term **endian** comes from _Gulliver's  Travels_ by Jonathan Swift (see here), where it refers to the trivial matter of which side people crack open their eggs.   * The terms **journal** and **transaction** refer to nearly identical concepts in both filesystem design and double-entry bookkeeping (financial accounting). `mkfs.ext2` even says:              Writing superblocks and filesystem accounting information: done      **Off-topic:**   * Learning to write English well is important, as it enables a programmer to document and evangelize his/her software, as well as appear competent to other programmers online.   * Trigonometry is used in 2D and 3D games to implement rotation and direction aspects.   * Knowing finance will come in handy if you want to write an accounting package.   * Knowing XYZ will come in handy if you want to write an XYZ package. **Arguably on-topic:**   * The Monad class in Haskell is based on a concept by the same name from category theory. Actually, Monads in Haskell are monads in the category of Haskell types and functions. Whatever that means...


title: How do I optimize a web application for high-latency users?

text: Basically, I have an application that does searches and requests results from a backend via long polling. It connects to the backend which collects results for 500 ms then sends them back to the client (I'm simplifying things here a bit of course). As we've optimized this, we've noticed a growing divide between users who search at night vs users that search during the day. Namely, users who search at night are _much_ slower than users that search during the day due to the fact that these users are mostly international and have higher latency. What are good high-level approaches to speeding things up for these users?


title: Hate repetition to the extreme

text: I program in a style that everything it's expensive or I really do hate repeating anything, mostly because I develop for embedded systems. So I get very annoyed when I **have** to do something that causes repetition. An example would be that in my current project, I am creating a Layout Manager. I had this huge function that did all the work of placing everything, which I don't mind as long as I comment well. Some point down the line I realise that something I do in that long function I need to do again somewhere else, like adjusting for something that is bigger than the current. But what got me really annoyed ( and why I'm posting ) is that the needed function requires three variables. To me those three variables are expensive and should only be computed once per call. But to refactor the code the way I need to I have to put the variables in the needed function. Now the variables gets evaluated three times. This is just an example, and things like this crop up a lot else where, so besides telling me those evaluations aren't expensive, at which point I'll say, "I'm still repeating it though", what can be done about this sort of thing, or, to my huge annoyance, is it unavoidable? _**Update:_** One of the main suggestions given is store the value. Using the example above again, storing the value does not seem viable. Mostly because the needed function takes two needed values which are used to compute the three variables. It would mean I would have to create an object, and feel free to correct me if I'm wrong, store the values and variables into the object and then test them if they had changed. In short, unless there are other ideas out there, it looks to be unavoidable. The only real thing you can do is minimise up to a limit. How deep do I create objects at the cost of property look ups? How many times to I repeatedly have to create those three variables? I hope you get the idea. There is also the fact maybe I could better refactor my code. I tend to write in huge functions and only pull out what I need, which is probably KISS's fault. I think need another acronym to balance things out :P .


title: Why isn't the arrow operator in C++ just an alias of *.?

text: In c++, the * operator can be overloaded, such as with an iterator, but the arrow (->) (.*) operator does not work with classes that overload the * operator. I imagine that the preprocessor could easily replace all instances of -> with (*left).right, and that would make iterators nicer to implement. is there a practical reason for -> to be different, or is that just a peculiarity of the language/designers?


title: Constraints in a relational databases - Why not remove them completely?

text: Is there any reason to build constraints between tables (inside SQLserver) nowadays? If so, when? Most applications in my area are built on object principles and tables are joined on demand. Demand are based on the need from the application. I won't load a bunch of constrained tables for a simple look- up, which in turn (after action) require one another simple lookup. ORM tools such EntityContext, Linq2Data, NHibernate are also handle the constraints by themselves, at least you know what tables that need each other. Doing constraints inside the server is just about making (forcing) same changes twice? This is usually not a question up for decision, but this database is designed quite different. The design looks regular good, mostly mirrored the objects used by the applications. What disturbing me is all constraints configured inside SQLserver with "not cascade". Which means that you have to play "seek and find" when coding new database queries. Some cases requires up to 10 levels of an exact order to make a single delete. This surprises me and I'm not sure how to handle it. In my simple world, that setting makes the constraints losing most of the purpose. OK if the database were accessed from hosts without knowledge of the design. How would you act in this scenario?   Why not just remove all constrains from db and keep them at application level?


title: What top companies look for in an Interview?

text: 1. Basically I am looking for what is it that you goof up and you are out from the remaining process ?   2. Are elimination rounds a fair way to judge a person ? Anyone can have a bad hour :-(    3. Should you code the best possible or should you get the Algorithm right ? I generally first code a workable solution and then work on it till a level I think it looks beautiful to me. Is this a wrong approach ? Recently I had a telephonic interview in which I was asked to write a variation of Level Order traversal in 20 minutes. I could get the Algorithm and working code in 20 minutes but couldn't get the Exception handling and the coding convention right, after which I didn't hear back from them :-( All the other questions in the interview went very well this was the only thing which was 'not upto the mark'. Needless to say I like the company and will apply again but want to get it right the next time :-) Please share your experiences and valuable suggestions.


title: What open source POSIX compliance test suites are available?

text: I'm working on a small open source project, ELLCC, that uses clang/LLVM as a cross compiler for various target processors. For the runtime environment, I'm using the NetBSD libraries and porting them to target Linux and standalone systems. I want to run a POSIX compliance test suite on the code. I've found the Open POSIX Test Suite, which looks like a good start, but it hasn't been updated since 2005. I've done some preliminary testing (with gcc and ecc under Linux), and it looks like it needs a few updates for modern compilers. My questions are:   1. Does the Open POSIX Test Suite live on somewhere in a more up to date form?   2. Are there other open source alternatives?


title: Examples of composition in software engineering?

text: In programming, various terms like abstraction are mentioned quite heavily. What, however, is composition? What is a basic but effective example of composition at play to result in good quality code (good quality meaning easy to understand, short and concise, etc).


title: How do I grok NHibernate's QueryOver API?

text: I've run into the limits of what NHibernate 3.0's LINQ provider is capable of and decided it's time to learn about one of the more powerful (or at least feature-complete) options: the `QueryOver` API. The problem is, I have zero experience with `ICriteria`, and all of the tutorials I've been able to find online either:   1. Assume I'm an `ICriteria` expert and simply show me how to convert ICriteria code to the new fluent interface, or   2. Are trivial "here's how you do an inner join" examples that don't really help me _understand_ more complex concepts like projections, subqueries, requirements, or whatever other magic the API is capable of. What should I read to really **learn** about QueryOver, and how to make full use of it?


title: How do I Integrate Production Database Hot Fixes into Shared Database Development model?

text: We are using SQL Source Control 3, SQL Compare, SQL Data Compare from RedGate, Mercurial repositories, TeamCity and a set of 4 environments including production. I am working on getting us to a dedicated environment per developer, but for at least the next 6 months we are stuck with a shared model. To summarize our current system, we have a DEV SQL server where developers first make changes/additions. They commit their changes through SQL Source Control to a local hgdev repository. When they execute an hg push to the main repository, TeamCity listens for that and then (among other things) pushes hgdev repository to hgrc. Another TeamCity process listens for that and does a pull from hgrc and deploys the latest to a QA SQL Server where regression and integration tests are run. When those are passed a push from hgrc to hgprod occurs. We do a compare of hgprod to our PREPROD SQL Server and generate deployment/rollback scripts for our production release. Separate from the above we have database Hot Fixes that will need to be applied in between releases. The process there is for our Operations team make changes on the PreProd database, and then after testing, to use SQL Source Control to commit their hot fix changes to hgprod from the PREPROD database, and then do a compare from hgprod to PRODUCTION, create deployment scripts and run them on PRODUCTION. If we were in a dedicated database per developer model, we could simply automatically push hgprod back to hgdev and merge in the hot fix change (through TeamCity monitoring for hgprod checkins) and then developers would pick it up and merge it to their local repository and database periodically. However, given that with a shared model the DEV database itself is the source of all changes, this won't work. Pushing hotfixes back to hgdev will show up in SQL Source Control as being different than DEV SQL Server and therefore we need to overwrite the reposistory with the "change" from the DEV SQL Server. My only workaround so far is to just have OPS assign a developer the hotfix ticket with a script attached and then we run their hotfixes against DEV ourselves to merge them back in. I'm not happy with that solution. Other than working faster to get to dedicated environment, are they other ways to keep this loop going automatically?


title: Any suggestions for pair programming with external resource?

text: I am a software engineer engaged in some extracurricular projects outside of my main gig. I was considering hiring a developer on Elance to assist me. Ideally, we would be a collaborative team where I can review their code and our "days" would overlap by a few hours. Ideally, when that persons day is over, I could do code review and then take off where they left off. Has anyone attempted this? Would it be practical to use a Rackspace Cloud Server for this effort where when one developer was done they just saved a VM image that would be accessible by another developer? Our development environment will be ASP.NET 4.0 MVC 3.


title: PyQt application architecture

text: I'm trying to give a sound structure to a PyQt application that implements a card game. So far I have the following classes:   * Ui_Game: this describes the ui of course and is responsible of reacting to the events emitted by my CardWidget instances   * MainController: this is responsible for managing the whole application: setup and all the subsequent states of the application (like starting a new hand, displaying the notification of state changes on the ui or ending the game)   * GameEngine: this is a set of classes that implement the whole game logic Now, the way I concretely coded this in Python is the following:               class CardWidget(QtGui.QLabel):         def __init__(self, filename, *args, **kwargs):             QtGui.QLabel.__init__(self, *args, **kwargs)             self.setPixmap(QtGui.QPixmap(':/res/res/' + filename))              def mouseReleaseEvent(self, ev):             self.emit(QtCore.SIGNAL('card_clicked'), self)          class Ui_Game(QtGui.QWidget):         def __init__(self, window, *args, **kwargs):             QtGui.QWidget.__init__(self, *args, **kwargs)             self.setupUi(window)             self.controller = None              def place_card(self, card):             cards_on_table = self.played_cards.count() + 1             print cards_on_table                  if cards_on_table <= 2:                 self.played_cards.addWidget(card)                 if cards_on_table == 2:                     self.controller.play_hand()          class MainController(object):         def __init__(self):             self.app = QtGui.QApplication(sys.argv)             self.window = QtGui.QMainWindow()             self.ui = Ui_Game(self.window)             self.ui.controller = self             self.game_setup()      Is there a better way other than injecting the controller into the Ui_Game class in the Ui_Game.controller? Or am I totally off-road?


title: Is it OK to include another person's open-source module in a project that you are uploading to GitHub?

text: This seems like it would be an obvious "yes". However, I just want to be sure and I've tried googling around to no avail. I am learning Python/Django and uploading all of the projects I'm creating to GitHub. I'm starting to add in existing modules from other open-source projects that do not belong to me. Is it still okay to upload MY projects to GitHub, even though they include other people's open source modules as well? Should I give them credit in the README, or by commenting where their code is included? Thanks.


title: How do I evaluate a .NET job?

text: I have been a programmer for a few years and until now I worked exclusively with PHP, although I did create a few small side projects in other languages. I'm currently interviewing with a non-IT that relies mainly on .NET and they seem to be willing to hire me. I probably should have thought of this sooner, but without commercial experience in .NET what questions should I ask to ensure that that job will help me advance my knowledge of the .NET platform or if they are doing .NET the right way (libraries, frameworks, third-party tools, etc.)?


title: Can C++ be used as a server-side web development language?

text: I'd like to get into web development using C++ as the "scripting language" on the server-side. My server infrastructure is *nix based, so doing web development in C++ on Azure is not applicable and C++/CLI ASP.NET is also not applicable. Separate from legacy CGI applications, can web development be done using C++ ? Thanks, Scott


title: Is it possible to combine C/C++ with web languages?

text: I would like to create a web application (meaning that will run from browser). The point is that I want to write just the UI in HTML5 + CSS + JS (or maybe even some PHP). On the other hand, I want to write the functionality of the application in C or C++. Then, I want to combine the code about the UI and functionality. Therefore, I would like to ask, whether it is possible to combine C/C++ code with web markup/programming languages?


title: Member functions vs. Non-member functions for math operators

text: I'm writing a linear algebra library (long story short, it's a school assignment) that involves matrices, vectors, etc. In the process of creating this library, I'm going to be creating functions that perform mathematical operations on objects. For example, transpose matrix, invert matrix, normalize vector, etc. I was curious as to what is the "best practice" for this sort of function... That is, should I make the function a member function, or non-member? (For clarity/library use sake) Example:               //Member function way:     B = A.transpose();     C = A.inverse();          //Non-member function way:     B = linalg::transpose(A); //Non-member transpose function in linear algebra namespace     C = linalg::inverse(A);      Is there some standard regarding these sorts of operations? Or, at least, is there a common way people do this? I'm leaning towards the first option, but I'd like to know if this is recommended.


title: Drawing the line between models & libraries?

text: As my webapps increase in size, so does the complexity. In order to keep my classes & files structured and easy-to-access, I am starting to get more and more confused: I have some very clearly defined data objects in my application - `orders`, `invoices`, `products` for example. All of those have their own entity object that handles enforcement of values and pure business logic along with a model that handles storage of each object to my persistent storage of choice (database). Ok - everything clear and separated that far. But what about a logic-heavy object like `users`? Users log in and out, change password (with everything that means - hashing, encrypting and so forth) and do a whole lot of interaction both in the database and with Sessions. Right now, I use an `Authentication`-class, a library, which carries all of these mentioned actions and a lot more. It does it's job, but It's kind of unclear to me **what I should put into a model and what should be a Library**?


title: Should I organize my folders by business domain or by technical domain?

text: For example, if I'm using some MVC-like architecture, which folder structure should I use:               domain1/         controller         model         view     domain2/         controller         model         view      Or:               controllers/         domain1         domain2     models/         domain1         domain2     views/         domain1         domain2      I deliberately left out file extensions to keep this question language- agnostic. Personally, I'd prefer to separate by business domain (gut feeling), but I see that most/many frameworks separate by technical domain. Why whould I choose one over the other?


title: Ways to describe or measure the learning curve for a new technology?

text: As I begin to learn some major new things beginning from zero, I wonder: is there any way to describe, perhaps even quantify, the height of a learning curve? Having worked at many places on many projects, and half the times not being a good fit, I see we all need better ways to describe skill levels and skills needed for a project. I'm interested, for the purposes of this question, in describing the amount of increase in skills/knowledge/savvy for someone to be effective on a given project, staying with the same employer or in the same situation generally. Example: The owner comes to me and says "Hey, this new thing, it's vital technology for our next major project. No one here knows much about it. How long will it take you to get up to speed on it?" (BTW, I want to consider only competent people. No PHBs or fanboys of glitzy new things. Those confounding factors are important in real life, but secondary to the main point here.) Loose relative words like "steep", "easy" etc don't mean much. The person learning the new thing, and their manager, may have different expectations. I'd like to find something more objective, even if not perfect. In some magically ideal world, we might say "it takes (n) hours to learn C++, to skill level (x), including all of OO, STL and (blah-blah) set of design patterns". Hours could be used to mark calendars, assign team members and generally plan well. But of course, we all come with different thinking styles, different past experience, different IQs, different levels of passion to know or use the new thing. And then, do you want to design it, fix it, or just use it? Hours might not be useful, even if there was some formula to account for all those factors. Personally, I learn new ideas in electronics or photography about 3 to 10 times faster than new ideas in software, but don't know if I'm comparing new ideas of the same "size". (And I'm not sure in what sense I mean "faster"; not necessarily hours or days.) In part, I'm wondering about the "size" of knowledge it takes to become competent at, or to master, a new technology. There is the rough rule that it takes 10,000 hours to master something. Maybe for becoming a superb flute player in the symphony, or to be a top-notch helicopter pilot, but obviously one can master tying their shows in far less time. Shoe-tying is a "small" skill, the others are worthy of full time careers. Maybe someday, with future discoveries in psychology, neuroscience and education theory, one could say something like: "it takes (n) million mental thought quanta to learn (new thing) given you already know x, y and z and have a natural talent for grokking (subject)." Then there's be a rule of thumb that a million thought quanta on average correspond to so many minutes or hours, with some of us faster or slower, affected by stress, health and other work. Yeah. Nice science fiction, but not useful today for deciding whether or not to accept a project, which candidate to hire, or making career changes. What can we do today to describe the steepness of the learning curve, or rather, the height of the hill we're climbing, metaphorically speaking? What's better than vague subjective generalizations?


title: Is it possible to get a job in corporate software houses without a degree

text: I have been developing web applications in PHP from two years and have worked with three organizations. I started with no programming knowledge at all, I had interest in web development so I read some books, followed tutorials and hang out with web developers to learn how to develop websites which took me to PHP and than eventually towards programming and I really enjoyed it. Learning OOP, studying servers behaviours, doing amazing things with JS, working and understanding with frameworks like Zend and Yii was quite an experience for me. My ideals also changed from movie stars to persons like Dennis Ritchie and Matt Mullenweg. It took a while to get a job when I got my first things became pretty easy but one thing that I came across while working in the small software houses is that they really don't worry about the code all they want is to get the thing done by any means so that can deliver the project on time to their clients. This is actually really disturbing I have switched two organizations just to excel in programming and contribute in the field of IT as much as I can but it doesn't seems possible if I continue working in the organizations which are much focused on client and don't bother to compromise on the quality of code. My dream companies are wordpress and the organizations which have developed open source PHP frameworks like zend, yii etc. Why? because they are AMAZING and just because of their contributions web has become so amazing and rapid development is in reach of every developer but I am not sure whether I will be able to get a chance in such companies or not because I don't have a degree not because I never wanted but because I really never had a choice. I was on my own from the teenage and it was not possible for me to afford the education and now when I have the resources I am lacking in time and focus. I have a full time job, blog and some responsibilities. Will it be ever possible to work in my dream companies or which are similar to my dream companies


title: Does test-driven development force me to follow SOLID?

text: I hear a lot from TDD practitioners that one of TDD's advantages is that it forces developers to follow SOLID principles (Single responsibility, Open- closed, Liskov substitution, Interface segregation and Dependency inversion). But as for me it is enough to just write some tests (unit test primarily) to understand it is important to follow SOLID (and thus create testable architecture). Does TDD force developers to follow SOLID more actively than just writing unit tests?


title: Is blocking java applets a necessary security measure?

text: Chrome 11 is now asking user permission to run both signed and unsigned Applets (yes, for signed applets the user is asked twice). Chromium team decided that this measure is needed even when the user is using an up-to-date JRE. Here's my bug report (which reflects solely my opinion: http://code.google.com/p/chromium/issues/detail?id=84001). My question is, how do you guys see it? Is Java Sandbox dated and unsafe? Do browsers need to impose a second layer of protection by default? **Update:** I'm also curious about how many of you guys have a clean record experience with Java against how many every hit a piece of malicious software? As a Java Power User for more than 10 years, the only time my antivirus ever complained about something related to Java was a false positive (I was downloading some libraries from Maven Central repository).


title: Why can't native machine code be easily decompiled?

text: With bytecode-based virtual machine languages like Java, VB.NET, C#, ActionScript 3.0, etc., you hear sometimes about how easy it is to just go download some decompiler off the Internet, run the bytecode through it one good time, and oftentimes, come up with something not too far from the original source code in a matter of seconds. Supposedly this sort of language is particularly vulnerable to that. I've recently started wondering why you don't hear more about this concerning native binary code, when you at least know which language it was written in originally (and thus, which language to try to decompile into). For a long time, I figured it was just because native machine language is so much crazier and more complex than typical bytecode. But what does bytecode look like? It looks like this:               1000: 2A 40 F0 14     1001: 2A 50 F1 27     1002: 4F 00 F0 F1     1003: C9 00 00 F2      And what does native machine code look like (in hex)? It, of course, looks like this:               1000: 2A 40 F0 14     1001: 2A 50 F1 27     1002: 4F 00 F0 F1     1003: C9 00 00 F2      And the instructions come from a somewhat similar frame of mind:               1000: mov EAX, 20     1001: mov EBX, loc1     1002: mul EAX, EBX     1003: push ECX      So, given the language to try to decompile some native binary into, say C++, what's so hard about it? The only two ideas that immediately come to mind are 1) it really is that much more intricate than bytecode, or 2) something about the fact that operating systems tend to paginate programs and scatter their pieces causes too many problems. If one of those possibilities is correct, please explain. But either way, why do you never hear of this basically? **NOTE** I'm about to accept one of the answers, but I want to kind of mention something first. Almost everybody is referring back to the fact that different pieces of original source code might map to the same machine code; local variable names are lost, you don't know what type of loop was originally used, etc. However examples like the two that were just mentioned are kind of trivial in my eyes. Some of the answers though tend to state that the difference between machine code and the original source is drastically much more than something this trivial. But for example, when it comes down to things like local variable names and loop types, bytecode loses this information as well (at least for ActionScript 3.0). I've pulled that stuff back through a decompiler before, and I didn't really care whether a variable was called `strMyLocalString:String` or `loc1`. I could still look in that small, local scope and see how it's being used without much trouble. And a `for` loop is pretty much the same exact thing as a `while` loop, if you think about it. Also even when I would run the source through irrFuscator (which, unlike secureSWF, doesn't do much more than just randomize member variable and function names), it still looked like you could just start isolating certain variables and functions in smaller classes, figure out how they're used, assign your own names to them, and work from there. In order for this to be a big deal, the machine code would need to lose a lot more information than that, and some of the answers do go into this.


title: How should a programmer plan his life for future

text: I have been doing web developmwnt for 3 years in php/joomla/jquery/mysql. I am now learning python/django/sysadmin/j2ee just to expand my knowledge. I am 28 and I can find jobs, but I was thinking if I go beyond 40 or 45 then there is every chance that companies will look for younger people, because you can always find young people with similar skills if not experience. So I was thinking, do I need to keep the same role as a web developer or do I need to seek a career path where age does not matter and experience is the key. I have a relative who worked for 15 years as a programmer, and is now 38. He became the recruiter for an agency which provides IT candidates to other companies. I think that sort of position is not linked to age. I may be wrong. The other option I was thinking of is to keep in mind that by the time I get to 40 or above, I should have enough links with clients so that I can get enough freelance work to make my living. Because then I don't have to be at the mercy of jobs, and age won't matter. So I just want to know: as programmer what is the future after 40 or 50? Because if we have that kind of goal, we need at least 10-15 years to get to that point.


title: Is just using an email address for login a good idea?

text: Many a times I need to log into a website that I used months ago and have forgotten my password. So clicking the reset password link and the site sends me an email with a single use link which allows me to enter a new password and logs me in. Happy days. This got me thinking; how about we skip the whole password thing and just send a single use link in an email that I click which logs me into a month long session. So, tell me. Why wouldn't this work?


title: What are the shortcomings of using AuthorizeAttribute in this way in MVC?

text: I have ASP.Net MVC project code with custom authorization as below:               public class UpdateAccrualAuthorize : AuthorizeAttribute     {         public override void OnAuthorization(AuthorizationContext authContext)         {             AccessPermissions securityObject = AppContext.CurrentUser.Permissions;             if (!securityObject.HasCostPageAccrualChangesAccess)             {                 authContext.Result = new RedirectToRouteResult(                                         new RouteValueDictionary(new { controller = Constants.HeaderPage.ErrorController, action = Constants.HeaderPage.AccessDeniedAction }));             }         }     }      Here the redirect route logic is inside the authorization logic Then I referred Changing my Action filter class to be a Custom authorization attribute. Here it says a different approach               if (!authorized)              base.HandleUnauthorizedRequest(filterContext);      and to make configuration entry               <system.webServer>         <httpErrors errorMode="Custom" existingResponse="Replace">             <remove statusCode="403" subStatusCode="-1" />             <error statusCode="403" path="/error/403" responseMode="ExecuteURL" />         </httpErrors>     </system.webServer>      and register a route               routes.Add("Error",                  new Route("error/{statusCode}", new { controller = "Error", action = "Details" })                            );      Update I also read Asp.net Mvc custom mechanism to handle unauthorized request about handling ajax requests in the AuthorizeAttribute **QUESTION** What are the advantages of this new approach over my approach?


title: debugging web applications using debug parameter

text: A suggestion has been made by a team member to leave all debug code intact in our web pages... and then to create a variable that can be turned on / off to enable / disable debugging. This is a technique we use in some of our low level, non web code. Just wondering if anyone had any comments on how they've implemented something similar for web applications? Some of our web applications are written in lua, and others in PHP. I like the idea and I've seen it used in different types of solutions. However, my knee-jerk reaction is that for web apps, it might not be such a great idea. I don't want to have a tonn of logs generated on the web server. At the same time, it'd be nice to simply enable a variable and then start collecting information. The alternative could be to always have a test page that calls the same methods that the production page does, but the test page dumps a bunch of data to the screen. Just wondering if anyone has any experience / comments on doing this for the web as far as how to build it in, how difficult it is to maintain etc. Thanks.


title: What's the best way to set up the distance and height of a triple monitor system

text: I am fortunate that my employer provides a triple monitor setup. However, I'm wondering if the greater degree of head turning and the closeness of the monitors is leading to some postural pain. Is there any advice or guidelines, specifically for _triple_ monitors which might be of use?


title: Current best practice/methods to code a VB.NET DAL in SQL Server

text: What are the current best practice/methods to code a VB.NET DAL in SQL Server? I have been trying to search but can't seem to find the right words to look for.


title: How does C++ handle multiple inheritance with a shared common ancestor?

text: I'm not a C++ guy, but I'm forced to think about this. Why is multiple inheritance possible in C++, but not in C#? (I know of the diamond problem, but that's not what I'm asking here). How does C++ resolve the ambiguity of identical method signatures inherited from multiple base classes? And why is the same design not incorporated into C#?


title: Is every page a new view?

text: I just started building an iOS app and wanted to get some feedback regarding views. I've got specs for               Activity Page     Activity Recording     Activity Create     Activity Save      Each of the specs show a different function, but would each of these be a brand new view in my iOS app?