title: Building a distributed system on Amazon Web Services

text: Would simply using AWS to build an application make this application a distributed system? For example if someone uses   **RDS** for the database server,   **EC2** for the application itself and   **S3** for hosting user uploaded media,   does that make it a distributed system? If not, then what should it be called and what is this application lacking for it to be distributed? **Update**   Here is my take on the application to clarify my approach to building the system:   1. The application I'm building is a social game for Facebook.   2. I developed the application locally on a LAMP stack using Symfony2.   3. For production I used an a single EC2 Micro instance for hosting the app itself, RDS for hosting my database, S3 for the user uploaded files and CloudFront for hosting static content. I know this may sound like a naive approach, so don't be shy to express your ideas.


title: Practical programming according to the Dependency Inversion Principle

text: What the Dependency Inversion Priciple implies in practice is that in a system, high level components should depend on abstractions of the low level components (instead of on the low level components directly), and the low level components should be defined in terms of these abstractions. The key point for my question is that _the low level components are defined in terms of the abstractions, which is defined in terms of the high level components_. Meaning: the high level components 'define the abstraction' in terms of what would be convenient for them, and the low level components have to be defined according to that abstraction (usually an interface). So if the high level component is a `Car`, and the low level component is the `Engine`, and an interface `IEngine` is defined - it will be defined according to the needs of the `Car`, and `Engine` will have to fit these needs. So if it's convenient for the `Car` to be able to simply start the engine, `IEngine` would feature a method `start()` and `Engine` would have to implement it. My question is: When starting programming on a project designed according to the Dependency Inversion Principle - are the high level components usually implemented before the low level ones, ie. "top to bottom" development? Since the principle implies that the low level components are designed according to what is convenient for the high level components, it makes sense to first start programming the high level components, and only then define the `ILowLevelComponent` interface, based on what we learned the high level components need when we programmed them. For example we're implementing a system that simulates a car. `Car` is the high level component, while `Engine` and `SteeringWheel` are the low level components. `Engine` and `SteeringWheel` take care of the concrete work of moving the car around, while `Car` takes care of coordinating everything and creating a functioning system. If we were designing the system according to DIP, that means that `Engine` and `SteeringWheel` are defined in terms of an abstraction, that is defined in terms of what is convenient for `Car`. So it would make sense to first implement `Car`, understand exactly how it's going to work in high level terms and what it needs to work, and only then define the `IEngine` and `ISteeringWheel` interfaces, according to what the `Car` needs. And then ofcourse implement the concrete classes that implement the interfaces. **So what I'm asking is: when working on a project that is designed in the spirit of DIP, is the "top to bottom development" approach common? Is this how work is usually done on project following the Dependency Inversion Principle?**


title: Have you worked with poorly designed application?

text: Well , I have been asked to work in a Java web application that is very very poorly designed . In the name of "making this easy" , they have come up with their own "framework" to make things extremely difficult to understand . I am struggling to figure out the control flow . Do you have any such experience ? What do you do in such situations when the guy who has "designed" it has already left the company ?


title: What do you do before you start programming?

text: I'm not sure this question belongs here, it's not so much I problem I'm having with programming but rather a problem of what to do before I start programming. I want a visual representation of what variables I need and what classes have what methods.I know there is UML but I'm not sure if that is the best way, so what do you guys use before you start programming, which method? I don't want to start a flamewar about what is better just what are several approaches?


title: What is a good design pattern to implement REST services on mobile?

text: It is easy to implement calls to API endpoints, then to parse JSON and handle the data - but what is a good design pattern for this? Here are some ways I have tried but I feel like there should be a better way:   1. Create a singleton class that manages all networking code and all data parsing code for the entire application for all endpoints. Then any controller class can hit the singleton   2. Make network endpoint tasks straight from view controllers - using blocks within the view controller to manage responses Consider an application that can hit an endpoint (GET) to download a list of appointments. Also consider an POST endpoint where you can send new appointments. Data must be packaged/unpackaged in JSON and errors must be handled appropriately. What is a good design pattern to accomplish this? And before you downvote this post and say its too broad or subjective just look at this page: https://programmers.stackexchange.com/help/dont-ask > Some subjective questions are allowed, but “subjective” does not mean > “anything goes”. All subjective questions are expected to be > **constructive**. A good answer to this common problem is hard to find.


title: What to do if a team member misses a sprint planning?

text: Lets say a team member is on an annual leave. He won't be attending sprint planning but he will be back by mid of iteration/sprint. Lets say he has 50% capacity i.e. as he will be available for later half of the iteration, should we:   1. have a planning session with him after he is back.   2. have a planning session with him before he goes on annual leave i.e. before sprint planning.   3. don't schedule him for any task and assign him on non sprint tasks e.g. spikes etc   4. have his peers plan on his behalf during sprint planning and absent person can then add tasks when he is back and if he cannot do all the work he can descope.   5. have him sit with another developer and do pair programming for a while.   6. anything else.. i am interested to know what you are doing.. Note: We are doing (1) and it doesn't feel right.


title: Going to coding conference -- bosses expectations reasonable?

text: Next week a coworker and I are being sent to a local coding conference. This morning our manager sent us an email pretty much telling us we need to take our laptops and hinted at doing a google document so he can see us take notes in real time. This really rubbed me the wrong way and both of us emailed him back. These emails I have posted below. I'm wondering if you guys have encountered these types of expectations from your bosses. I've been a professional programmer for over 10 years and have never had this type of micro management about being sent to a conference. Just wondering if "coworker" and I are not seeing things clearly or if our boss is being a little weird about this. * * * From: Boss Sent: Friday, March 25, 2011 11:51 AM To: Coworker; Me Subject: Re: DevConnections next week Really guys? Whatever works for you, I guess. But I'm expecting that you have detailed enough notes to adequately share sessions you attend, including any URLs for supporting information, etc. This is not a "would be nice" but a professional expectation for attendance at these type of events. \--Boss On 3/25/11 10:08 AM, "Coworker" wrote: > The hotel where the conference is being held is huge. "Lugging around your > laptop" is an accurate description he he. > > I myself am not a classical learner. I learn by paying attention, > participating in the class topic, and asking questions. If I try to take > notes it's destructive to my learning process. A gifted teacher in community > college, Dr. Phar, pointed this fact out to me and told me I was a "visual > learner". After that I was able to excel in college and obtain my Master's > Degree. > > To meet Boss's requirements I generally take a half day after the conference > to put together some presentation material for the team. > > Coworker > > \-----Original Message----- From: Me Sent: Friday, March 25, 2011 9:48 AM > To: Boss; Coworker Subject: RE: DevConnections next week > > Thanks for the reminder. I was definitely planning to take a notebook to > take notes and have no problem sharing information I come back with, but I > would rather not lug around the laptop if I have the choice. Is that ok? > Maybe we could take our laptops and keep them in the trunk in case of a work > emergency? What do you think? > > Me > > \-----Original Message----- From: Boss Sent: Friday, March 25, 2011 8:39 AM > To: Me; Coworker Subject: DevConnections next week > > Coworker / Me, > > Don't forget to take your laptops next week and take notes to share with the > team. As in the past, we can schedule a review session to share the > highlights. Maybe use Google Docs and share your notes with me and . >Also, > take some time to coordinate your session attendance to help hit all the > good topics. > > Have fun, Boss


title: Questions about UML in relation to the command pattern

text: http://www.oodesign.com/command-pattern.html In reading through a tutorial about the command pattern, I came across a UML diagram that seems to omit some relationships. For the following diagram, the client instantiates a stock trade, an agent, and buy and sell stock orders. Why is it that the author omits the relationship arrow to the agent class? Why is the dashed line for <> used in place of a solid arrow like the one from Client to StockTrade? ![enter image description here](http://i.stack.imgur.com/9clLI.gif) I also compared the above diagram with the one below, which leaves out the Invoker/Agent class entirely and also uses the class CallbackTwo to aggregate Receivers. The C# implementation has an invoker class, although the implementations in other languages don't. Does this mean the invoker relationship is implicit? http://sourcemaking.com/design_patterns/command http://sourcemaking.com/design_patterns/command/c-sharp-dot-net ![enter image description here](http://i.stack.imgur.com/GljS8.png)


title: "Whole-team" C++ features?

text: In C++, features like exceptions impact your whole program: you can either disable them in your whole program, or you need to deal with them throughout your code. As a famous article on C++ Report puts it: > Counter-intuitively, the hard part of coding exceptions is not the explicit > throws and catches. The really hard part of using exceptions is to write all > the intervening code in such a way that an arbitrary exception can propagate > from its throw site to its handler, arriving safely and without damaging > other parts of the program along the way. Since even `new` throws exceptions, every function needs to provide basic exception safety — unless it only calls functions which guarantee throwing no exception — _unless you disable exceptions altogether in your whole project_. Hence, exceptions are a "whole-program" or "whole-team" feature, since they must be understood by everybody in a team using them. But not all C++ features are like that, as far as I know. A possible example is that if I don't get templates but I do not use them, I will still be able to write correct C++ — or will I not?. I can even call `sort` on an array of integers and enjoy its amazing speed advantage wrt. C's `qsort` (because no function pointer is called), without risking bugs — or not? It seems templates are not "whole-team". Are there other C++ features which impact code not directly using them, and are hence "whole-team"? I am especially interested in features not present in C. **Update** : I'm _especially_ looking for features where there's no language- enforced sign you need to be aware of them. The first answer I got mentioned const-correctness, which is also whole-team, hence everybody needs to learn about it; however, AFAICS it will impact you only if you call a function which is marked `const`, and the compiler will prevent you from calling it on non- const objects, so you get something to google for. With exceptions, you don't even get that; moreover, they're always used as soon as you use `new`, hence exceptions are more "insidious". Since I can't phrase this as objectively, though, I will appreciate any whole-team feature. **Update 2** : instead of C++ feature I should have written something like "C++-specific feature", to exclude things like multithreading which apply to a large amount of mainstream programming languages. ### Appendix: Why this question is objective (if you wonder) C++ is a complex language, so many projects or coding guides try to select "simple" C++ features, and many people try to include or exclude some ones according to mostly subjective criteria. Questions about that get rightfully closed regularly here on SO. Above, instead, I defined (as precisely as possible) what a "whole-team" language feature is, provide an example (exceptions), together with extensive supporting evidence in the literature about C++, and ask for whole-team features in C++ beyond exceptions. Whether you should use "whole-team" features, or whether that's a relevant concept, might be subjective — but that only means the importance of this question is subjective, like always.


title: best practices in creating a product backlog in scrum

text: I am new to scrum, project management in general, and i am having problems deciding what to call a feature or a sub-feature (which are tasklists to creating that feature?) especially for the standard things we have in every web app. So i am looking for best practices on how people are creating product backlogs for a typical website software (users, profiles, admin, front-end) . I have this in mind as an example.                - feature: home page           - feature: contact us page           - feature: admin panel                 - create user                    + create database (tasklist)                    + write stored procedures (tasklist)                 - delete user                 - add content                 - delete content           - feature: subscribe                  - create subscribe page      Also, how granular is too granular?


title: Once and only once - with more lines of code

text: I have an ugly bit of code - essentially iteration over some data structures where the meat of the action was changing, but the iteration code stayed same. The iteration constituted the bulk of code, and there were at least four cases of code copying. So I refactored the code, putting each level of iteration into its own class (I'll probably do another post on it later).The new code is considerably nicer (at least to my eye), with no copy/paste locations. However, due to some infrastructure I had to introduce to refactor nested loops into separate classes, I ended up with 10% larger number of LOCs. If I discount the extra infrastructure, I get about 5% smaller code compared to the original size. So, the code is more sophisticated, but it is not shorter and may be harder to understand for a less experinced programmer. I may still end up with shorter code in the future if more oppotunities for reuse present themselves. My question is: do you think it was worth it? Is it a good idea to refactor for "once and only once" if the LOC count goes up?


title: How to identify hackers based on ip addresses and the pages that were accessed

text: I saw some suspicious errors being generated on my site based on pages that were requested. My error is logging the path that the user is trying to access. Because of these errors (and the paths that they were trying to access) I created my own blacklist process where I can blacklist someone from my site based on ip address and/or username. After implementing this, I didn't see ANY errors of that kind....until today. Now, before I go ahead and blacklist this person, I'd like to make sure that it isn't a legitimate search engine just trying to build it's database with all links available from my site. So, my question, is there a way to see what company an ip address is assigned to? Or, do those crawlers from search engines only go to pages that exist?


title: Area of testing

text: I'm trying to understand which part of my code I should to test. I have some code. Below is example of this code, just to understand the idea. Depends of some parametrs I put one or another currency to "Event" and return his serialization in the controller. Which part of code I should to test? Just the final serialization, or only "Event" or every method: getJson, getRows, fillCurrency, setCurrency?               class Controller {         public function getJson()         {             $rows = $eventManager->getRows();                   return new JsonResponse($rows);         }     }          class EventManager {         public function getRows()         {             //some code here             if ($parameter == true) {                 $this->fillCurrency($event, $currency);             }         }              public function fillCurrency($event,  $currency)         {             //some code here             if ($parameters == true) {                 $event->setCurrency($currency);             }         }     }          class Event {         public function setCurrency($currency) {             $this->updatedAt = new Datetime();             $this->currency = $currency;         }     }


title: Picture Parsing

text: If I open a picture file, lets say with an PNG extension, I will see bunch of code. Now let say I want to get some information from the picture mechanically. So the question here is what is the first step here, do I need to parse the picture?. If so how can I get the grammar for picture files? (PNG, JPEG, etc.) UPDATE: Found an issue with my thinking!. Parsers are for text-based languages, however pictures are binary files. So, I dont think we need to parse them we need to go in the opposite direction and turn them into abstract syntax trees, wondering how to do so without knowing the grammar!


title: Is C++.Net used extensively?

text: I am a C++ coder by tradition. Over the last 12 months or so I have been doing a lot of C# coding, and have been pleasantly surprised by C#'s pragmatic approach (once I stopped trying to code it as if it was "C++ with garbage collection"). We have recently had some graduates in and when helping one of them I realised she was using .Net within C++. After asking her why, she said she had been "told to use C++ by her manager". Obvious communication problem aside, I assume she was using .Net because that's the only framework she's been exposed to. I then came across an old project by a senior developer who also used C++ to drive a Forms front end. Now this would have been written around the time .Net first appeared, so I assume it was a learning exercise on his part to play around with .Net. It was only a small utility app. Having had to do some minor modification in this app, it seemed to me that using C++ to drive .Net gives you the worst of both worlds. No garbage collection or memory safety, but no similarly no real speed/optimisation opportunities since you're dealing with a managed framework. So my question is whether people do use C++ .Net for any large stand alone (ie non-plumbing) production code, and if so what are your reasons for doing so? I freely admit I have never delved deeply into the C++ .Net extensions so I may be doing it a disservice.


title: Which open source PHP project has the 'perfect' OOP design I can learn from?

text: I am a newbie to OOP, and I learn best by example. You could say this question is similar to Which Scala open source projects should I study to learn best coding practices \- but in PHP. I have heard-tell that Symfony has the best 'architecture' (I will not pretend I know what that exactly means), as well as Doctrine ORM. Is it worth it to spend many months reading the source code of these projects, trying to deduce the patterns used and learning new tricks? I have seen equal number of web pages dissing and liking Zend's codebase (will provide links if deemed necessary). Do you know of any other project that would make any veteran OOP developer shed tears of joy? Please let me add that practicality and scope of use is not a concern at all here - I just want to do:   * Pick a project that has a codebase deemed awesome by devs way better and greater than me.   * Write code that achieves what the project does.   * Compare results and try to learn what I don't know. Basically, an academic interest codebase. Any recommendations please?


title: C programming practice, passing a pointer to a function

text: Consider the following C function which takes as argument a string, which is then stored inside a struct:               struct mystruct* usestring(char* string)     {         struct mystruct *struct;         struct = malloc(sizeof(struct mystruct));         struct->string = string;         return struct;     }      My understanding is that the string passed to the function is the same string that is stored inside the struct. What is the proper etiquette in this situation? Should I make a copy of the string and store that in the struct, or should I expect that the function caller will not modify the string later?


title: Actor library / framework for C++

text: In the C++ project I am working on, we have an application consisting of several processes deployed on different machines. This network of processes is dynamic since processes (clients or background services) can be started and terminated during the application's lifetime. We have already a module that allows to transport arbitrary data over the network through RPC, and we are using it to exchange information (such as status information, progress information, error codes, etc) between the processes. We would like to have a more abstract layer to handle asynchronous communication (currently, the RPC is executed synchronously), and to allow processes to be started and terminated dynamically and still find each other. We recently looked for a solution and we think we can use something like Scala **actors** and **remote actors** (see e.g. this tutorial). Another language using the actor model that has been around longer than Scala is Erlang (see also this question). Actors are objects that have a behaviour and a mailbox, share no data. Actors are executed concurrently, and communicate through asynchronous message exchange. As part of their behaviour, actors can create other actors. Messages are also represented as objects. The simplest case is that actors live in the same process. In this case they can address each other using a handle (reference, pointer, unique identifier). The actor implementation hides the underlying threads and any other details. When actors live in different processes (and possibly on different machines in a network) they are identified by an IP address, a port and a name. In this case we speak of **remote actors** (see the short example at the top of this page). In our case, we would have one actor on each process, taking care of all the communication, i.e. we need some kind of remote actors. On wikipedia I have found some links to actor libraries for C++ and I have started to look at Theron. Theron seems a very well-written and documented library but, to my understanding, it does not support remote actors: all actors must live within the same process. It is possible to create several actor pools ( **frameworks** ), but all these pools must live in the same process. So I wanted to ask if someone knows other C++ libraries that support the remote actor concept as sketched above. **EDIT** This question has been edited wrt the original question, following indications from programmers-meta discussion. **UPDATE** Other frameworks I have looked at are libcppa (should support remote actors, but it is still under development, currently version 0.1), actor-cpp (also under development), and libactor, which is in C (the web site says it "is usable, although it may not be ready for production").


title: Design pattern for access to tree-like database in Java?

text: I'm developing a Roleplaying character viewer/manager programme for a locap LARP system. The Characters have access to skills that are layed out in a tree-like structure. There are a lot of skills, and potentially a lot per character. I know I can just import the Java swing library to get access to a tree, but I feel like this may bog me down, when all that needs to be done is access to a tree-like database, and the character needs only know that they have access to a subset of the skills. I'm not sure if the tree design pattern is the best choice for this (i.e. instantiate a tree for the skills known per character, and add to/delete parts as needed) or 'do the clever stuff' and use a list per character to see which parts (skills) of database (external tree) are 'owned'. My skills are broken down roughly as so:   `Course catogory -> Weapon Type -> Actual Weapon -> Proficiency-->Special Skill`, which goes quite deep. Further to this there is little need to know what is at each level, just that it's children, until you hit the leaf, and the one up. My database effectively already exists on the LARP website, so if I don't have to reproduce it, that would be good. Here is a sample               Weapons and Shields     Warrior Priest Scout Mage      1H Weapon Proficiency     3        6     6     9      1H Weapon Specialisation  6        12    12    18      1H Weapon Expertise       12       24    24    36      1H Weapon Mastery         24       48    48    72       And later on:               Magic           Warrior       Priest        Scout         Mage      Learn Spell     9 x (l + 1)   9 x (l + 1)   6 x (l + 1)   3 x (l + 1)      l = spell level,       ...     Create Talisman 9 + l         9 + l         6 + l         3 + l      l = level,


title: What would you choose for your project between .NET and Java at this point in time?

text: You are just starting a new project and you have these two technologies to choose from, Java and .NET. The project you are working doesn't involve having features that would make it easy to choose between the two technologies (e.g. .NET has this that I need and Java does not) and both of them should work just fine for you (though you only need one of course). Take into account:   * Performance    * Tools available (even 3rd party tools)   * Cross platform compatibility   * Libraries (especially 3rd party libraries)   * Cost (Oracle seems to try and monetize Java)   * Development process (Easiest/Fastest) Also keep in mind that Linux is not your main platform but you would like to port your project to Linux/MacOs as well. You should definitely keep in mind the trouble that has been revolving around Oracle and the Java community and the limitations of Mono and Java as well. It would be much appreciated if people with experience in both can give an overview and their own subjective view about which they would choose and why.


title: Found a better solution to a problem at work - should I deter from posting the code snippet online?

text: I think most of us, programmers, used Stack Overflow to solve every day problems: looked for an efficient algorithm to do something. Now imagine a situation: you have a problem to solve. Googled a bit, found a StackOverflow question but you are not really satisfied with the answers so far. So you have to do your own research: you need to do it because you want it in the company's app. Eventually after some hours you have found the better solution. You're happy, you added it to the company's code base, then you want to submit your answer with a code snippet (just several lines) to the question you've found before to help others too. But wait: the company's software is closed source, and you worked on it on the clock. So does this mean I shouldn't post the answer neither at work nor at home to that question in the rest of my life, because I solved it at work, and the company owns that piece of code?


title: Resume dilemma for professional job

text: On my resume, I list myself as having "7 years of hands-on experience programming in C". To clarify, I am a self-taught C programmer with some college courses thrown in the mix. I've worked on some small personal projects, and I consider myself to be more competent than a Computer Science grad with no actual real-world experience, though by no means am I anywhere near being an expert. The issue is this... I keep getting calls and emails from recruiters that see my resume on job sites, inquiring about my interest in senior developer positions, contracts, etc., of which I feel that I am completely under- qualified for. My resume only has 3 years of work experience listed (which is all IT stuff), so when they ask about my prior experience in C, I have to clarify that it was personal work, not professional work. I'd really like a job as a developer, but I don't want to get hired for something that I can't handle, nor do I want to misrepresent myself while trying to show off my strengths. I deliberately chose the phrasing "hands-on" to imply that it wasn't professional. How should I phrase my C experience on my resume to clarify it better?


title: Is there benefit to maintain a large project with bad code?

text: I'm currently maintain a large project with more than 100000 LOC. The code use the MFC as its framework, in genral, it only has interface part which heavily use the mfc api and a business logic part which full of bad code, confusing logic. The company has some small features delivered to the customer each year(most features are adding code to exisiting project, finding some reference of some api or variable and it' s no different with fixing 3-4 bugs ), most of the tasks are to resove issue and optimize performance . Like other company with maintaining position, it value people who knows much logic about its product. There are people who can quickly finish the job on such project, is it worth to train myself like such a programmer? Is there benifits to work on such project for a long time?


title: Programmers clipboard monitor under Windows

text: In the process of adapting a "put on clipboard"-solution to new behavior I have found that I need a good _programmers_ clipboard monitor for Windows. I do not need to have a history of items on the clipboard, but I need to see the details of what is currently placed there, including - this is important - the various flavors (RTF/HTML/plain text/etc) to be sure that all those I place there are correct. Free is preferred, but cheap will do. We are a Java shop, but I can install a Visual Studio Express edition if that makes things easier. (EDIT: The development box is Windows 7 64-bit) Any suggestions?


title: Books/sources on inner workings of JavaScript

text: When I started studying C++ a couple of years ago, a lot of the books and texts I read did a very thorough job of explaining, how the code written would translate into concrete operations in the hardware (like dynamically memory allocation, pointer arithmetics etc.). I found those explanations extremely helpful in order to fully understand the language. Now I am studying JavaScript and learning about the whole functional programming paradigm, with functions as first class objects and so on. I have read a lot of texts and books about how to use JavaScript, but I have yet to come across a source, that explains the low-level inner workings of the language (like how a function is represented in memory, what excactly happens when a function is called with .apply() and a new context is provided etc.). I guess you could say, that what I am looking for is the knowledge needed to write a JS compiler/VM..? How the runtime environments handle the different aspects of the language at a low level. Does anyone know where to find books or text, that goes into the very low level details of the language?


title: Background & Research Methods section (Writing an Article)

text: It is my first time writing an _article_ on a software project. I am supposed to use ACM UbiComp paper format. I already have a structure that I should follow and there is a **Background & Research Methods** section after Abstract, Introduction, Related Work sections. I have browser through several articles, but some of them either dont have it, have only background section or have only research methods section. **I am having hard time to find an article that has this section and moreover what I must write on here**. My project is about Bluetooth location tracking and I do have the implementation and evaluation, so it is not something theoretical.


title: How this Fibonacci exponentiation by squaring algorithm works?

text: This is one of the best algorithms to calculate the nth Fibonacci sequence. it needs O(log(n)) time to do its job, so it's so efficient. I found it somewhere but don't know how it works! Can anyone tell me how this algorithm works? thanks. Here's the code:               int fib3 (int n) {              int i = 1, j = 0, k = 0, h = 1, t;         while (n > 0) {             if (n % 2) {                 t = j * h;                 j = i * h + j * k + t;                 i = i * k + t;             }             t = h * h;             h = 2 * k * h + t;             k = k * k + t;             n /= 2;         }         return j;     }


title: Can I display part of the source code of an open source plugin's with GPLv2 liscence?

text: I would like to publish part or full source code of one or more plugins (licensed under GPL, GPLv2, MIT or no license) in my website/blog. Website I am talking about is for everyone, free to use and free to copy code. Plus, is it okay if I do not provide any link to the source code/plugin? I will definitely give full credits to the developer.


title: Should a new programmer focus on a single technology until he's proficient at it?

text: Ok, I've been teaching a buddy how to program for a while now. He's a very fast learner, and he's quite good at programming so far. However, he has one "issue" I keep trying to correct. He jumps in and starts doing highlevel programming without learning some of the basics (He's created a full blown web application but still doesn't know pagination or session management). This isn't the problem though. He keeps jumping around to new technology (Node.js, MongoDB, EC2, etc). I tried telling him that he should learn some of the basics about his RDMS of choice (MySQL) as he uses it everyday before investing a bunch of time into learning the basics of MongoDB (And probably moving to something new). Am I the one in the wrong here, or should he try to focus on one thing at a time and get really good at it?


title: Unit Testing: "It's a code smell if you're refactoring and there are no collaborators"?

text: I'm reading The Art of Unit Testing by Roy Osherove. I'm at section 7.2 Writing maintainable tests where the author has this note about code smell: > NOTE: When you refactor internal state to be visible to an outside test, > could it be considered a code smell (a sign that something might be wrong in > the code's design or logic)? It's not a code smell when you're refactoring > to expose collaborators. **It's a code smell if you're refactoring and there > are no collaborators (so you don't need to stub or mock anything).** **EDIT** : What the author means by "collaborators" is dependencies. Some of his examples for dependencies are classes that access a database or that access the OS's file system. Here is where he defines stub and begins to use the word collaborator: > A _stub_ is a controllable replacement for an existing **dependency** (or > **collaborator** ) in the system. The author doesn't have an example of this code smell and I'm having trouble understanding/picturing what this would look like. Can someone explain this a little more and perhaps provide a concrete example?


title: Advantage/disadvantage of parameters / return types declaration in languages with type inference

text: I would like to know your opinion on declaration by hand of parameters/return types in languages with type inference like Scala. Is there any reason why to or not to do this when compiler can infer types?


title: Functional Programming: Are Tuples a viable replacement for Types?

text: A while ago I decided to learn Haskell to help with learning more "pure functional" ideas that I could apply to F#. Right off the bat it seems as if there's no real types in Haskell like the ones that F# has. I'm fine with that so I wanted to find a way to remove myself from the hybrid OO/Functional design I've used in F# and really try to go classless and truly develop a function centric design. The first thing that came to mind when using Haskell was to just pass tuples around as they can hold information in key value pairs much like dynamic languages but don't have the constructor syntax like F# types. For example in F#:               type DatabaseWorkValueItem(firstItem, secondItem, thirdItem) =       member public x.FirstItem = firstItem       member public x.SecondItem = secondItem       member public x.ThirdItem = thirdItem      And this would be in my new proposed design:               module DatabaseWorkValueItem =            let firstItem (item, _, _) = item       let secondItem (_,item, _) = item       let thirdItem (_,_, item) = item            --Replace constructor with method       let CreateValueItem (parameter:String, value:Object, sqlType:SqlDbType) =         (parameter, value, sqlType)            --Replace properties with more methods       let GetDataType (item :(String *Object * SqlDbType)) =          thirdItem item            let GetParameter (item :(String *Object * SqlDbType)) =          firstItem item            let GetValue (item :(String *Object * SqlDbType)) =          secondItem item      They both get the same idea. One creates a class like Type with properties set on construction and the other uses all functions to create and read a tuple. Question is: Am I crazy to bother with this? Although I realize F# has the convenience of jumping between two paradigms, I can't help but feel that it's a comfort blanket to


title: Can unit testing software be used to unit test itself?

text: QUnit advertises itself on its web page like this: > ...capable of testing any generic JavaScript code, including itself! Can you really use unit testing software to test itself? Wouldn't defects in the software mean that the results are unreliable?


title: How to Document the Security/Encryption Code of an Application

text: I am working on an application that I developed a security layer for. It uses the hardware ID of the hard drive, MAC address and another hardware serial key, to lock the software a particular piece of hardware. I came across sites online, that said I should use fairly weird names for the procedures/functions/variables in the the security layer. For instance               function XtDmat: Boolean;      var       x3mat: string;       hhiTms: Interger;     begin       Result := False;       x3mat := GWindosColr;  //this returns the HD ID       hhiTms := GalilDriverID; //this gets a controller ID       if (t5gFx=x3mat) and (hhiTms=f4teXX) then Result := True; //match IDs with those saved in the registry     end;      And for the messages dialog box:               procedure Tfrm_MainWindow.mxProtectorExpiration( Sender: TObject );     begin       lbl_Remaining.Caption := GetClassPath('xsedfers34;;''kd'); // encrypted value  decryted and shown       '0 days remained'       lbl_Message.Caption := GetClassPath('qwe23vftTxxx ii gtr');   //decryt and show       'This license has expired'       btn_Go.Enabled := False;     end;      I did this because I used Delphi DEDE to decompile my code and found even the registry key 'HCKU\software\myapplication' to be in plain sight. Now, however, it has become difficult to   1. explain to my fellow team mates, why I did this (meaning the names),   2. document as the names do not make sense,   3. debug which gives me headaches. Can anyone suggest a good way to document this type of code in this type of situation. So the code becomes easier to, but is still diffcult to decompile. Alternatively, could one suggest a obfuscator for Delphi.


title: How is Delphi XE2 going to work across platforms?

text: So I've been reading a little about Delphi XE2 and I probably will go to the world tour thing in Chicago coming up later this month and ask this question if no one can answer it here. What I wonder is how is my Delphi code going to be executed on a Mac? Is something else going to have to run (i.e. virtual machine) in order for the program to run?


title: Linking Libraries in iOS?

text: This is probably a totally noob question but I have missing links in my mind when thinking about linking libraries in iOS. I usually just add a new library that's been cross compiled and set the build and linker paths without really know what I'm doing. I'm hoping someone can help me fill in some gaps. Let's take the OpenCV library for instance. I have this totally working btw because of a really well written tutorial( http://niw.at/articles/2009/03/14/using-opencv-on-iphone/en ), but I'm just wanting to know what is exactly going on. What I'm thinking is happening is that when I build OpenCV for iOS is that your creating object code that gets placed in the .a files. This object code is just the implementation files( .m ) compiled. One reason you would want to do this is to make it hard to see the source code and so that you don't have to compile that source code every time. The .h files won't be put in the library ( .a ). You include the .h in your source files and these header files communicate with the object code library ( .a ) in some way. You also have to include the header files for your library in the Build Path and the Library itself in the Linker Path. So, is the way I view linking libraries correct? If , not can someone correct me on this ?


title: In Java, would you sacrifice type safety for a nicer programming interface

text: **When and why would you generally sacrifice typesafety for a nicer programming interface?** Let me give you an example: if you had the choice between two event aggregators, which one would you prefer and why? Reflective Version:               SomeEvent.subscribe(instance, "nameOfAMethod"); //method called via reflection     SomeEvent.fire(arg1, arg2);  //the firing could actually even be statically typed      Statically typed version:               EventSystem.getEvent(SomeEvent.class).subscribe(new EventHandler<Payload>() {        public void eventOccurred(Object sender, Payload payload) {            //event handler code here        }     });          EventSystem.getEvent(SomeEvent.class).fireEvent(payload);      Please note, that in Java, due to type erasure, you cannot implement a generic interface with different type parameters more than once and need to resort to anonymous or external classes for handlers. Now the reflective event system has a nicer user interface, but you lose type safety. Which one would you prefer? Would you create empty event classes just for the sake of having a symbol, like Microsoft does it with PRISM in its event aggregator?


title: Why is there never any controversy regarding the switch statement?

text: We all know that the `goto`statement should only be used on very rare occasions if at all. It has been discouraged to use the `goto` statement countless places countless times. But why it there never anything like that about the `switch` statement? I can understand the position that the `switch` statement should always be avoided since anything with `switch` can always be expressed by `if...else...` which is also more readable and the syntax of the switch statement if difficult to remember. Do you agree? What are the arguments in favor of keeping the 'switch` statement? It can also be difficult to use if what you're testing changes from say an integer to an object, then C++ or Java won't be able to perform the switch and neither C can perform switch on something like a struct or a union. And the technique of fall- through is so very rarely used that I wonder why it was never presented any regret of having switch at all? The only place I know where it is best practice is GUI code and even that switch is probably better coded in a more object-oriented way.


title: overriding implemented base class methods

text: I read somewhere that the chain of inheritance breaks when you alter a behavior from derived class. What does "altering a behavior" mean here? Is overriding an already implemented method in base class considered as "altering behavior"? Or, does the author mean altering method signatures and the output? Also, I ready Duplicating code is not a good practice, and its a maintenance nightmare. Again, does overriding an already implemented method in base class considered "Duplicating code"? If not, what would be considered as "Duplicating code"? I


title: Ordering if conditions for efficiency and clean code

text: This is purely a design question and the example is simple to illustrate what I am asking and there are too many permutations of more complex code to provide examples that would cover the topic. _I am not referring specifically to this example, just using the example to illustrate what I am referring to._ In an if statement, is there a preferred way to order conditions, in terms of coding convention and, more importantly, efficiency? For such a simple example, efficiency will not be an issue, but I am not asking for a code review per se, but an understanding of the concept. Two alternatives:   1.               public double myStuff(int i)     {         // check for an invalid number of tourists         if (i > 0)         {             // do something here                  return doubleSomething;         } else         {             return Double.NaN;         }     }      2.               public double myStuff(int i)     {              if (i <= 0)         {             return Double.NaN;              } else         {                  {                 // do something here                      return doubleSomething;             }      If the if statement was to become more complex, and possibly nested, in what order should conditions be addressed?


title: Understanding HTTP Cookies in Indy 10 for Delphi XE2

text: I have been working with Indy 10 HTTP Servers / Clients lately in Delphi XE2, and I need to make sure I'm understanding session management correctly. In the server, I have a "bucket" of sessions, which is a list of objects which each represent a unique session. I don't use username and password to authenticate users, but I rather use a unique API key which is issued to a client, and has an expiration. When a client wishes to connect to the server, it first logs in by calling the "login" command, which is a path like this: `http://localhost:1234/login?APIKey=abcdefghij`. The server checks this API Key against the database, and if it's valid, it creates a new session in the bucket, issues a new cookie (unique string), and sets the response cookies with `Success=Y` and `Cookie=abcdefghij`. This is where I have the question. Assuming the client end has its own method of cookie management, the client will receive this login response back from the server and _automatically_ save the cookies as necessary. Any future request from the client to the server shall automatically send along these cookies, and the client side doesn't have to necessarily worry about setting these cookies when sending requests to the server. Right? PS - I'm asking this question here on programmers.stackexchange.com because I didn't see it fit to ask on stackoverflow.com. If anyone thinks this is appropriate enough for stackoverflow.com, please let me know.


title: Entity Framework Entities - Some Data From Web Service - Best Architecture?

text: We are currently using Entity Framework as an ORM across a few web applications, and until now, it has suited us well as all our data is stored in a single database. We are using the repository pattern, and have services (the domain layer) which use these, and return the EF entities directly to the ASP.NET MVC controllers. However, a requirement has come up to utilise a 3rd party API (through a web service) which will give us extra information that relates to the user in our database. In our local User database, we will store an external ID which we can provide the to API to get additional information. There is quite a bit of information available, but for the sake of simplicity, one of them relates to the user's company (name, manager, room, job title, location etc). This information will be used in various places throughout our web apps - as opposed to being used in a single place. So my question is, where is the best place to populate and access this information? As it is used in various places, it's not really sensible to fetch it on an ad-hoc basis wherever we use in the web application - so it makes sense to return this additional data from the domain layer. My initial thought was just to create a wrapper model class which would contain the EF entity (EFUser), and a new 'ApiUser' class containing the new information - and when we get a user, we get the EFUser, and then get the additional info from the API, and populate the ApiUser object. However, whilst this would be fine for getting single users, it falls over when getting multiple users. We can't hit the API when getting a list of users. My second thought was just to add a singleton method to the EFUser entity which returns the ApiUser, and just populate it when needed. This solves the above problem as we only access it when we need it. Or the final thought was to keep a local copy of the data in our database, and synchronise it with the API when the user logs in. This is minimal work as it's just a synchronisation process - and we don't have the overhead of hitting the DB and API every time we want to get user information. However, these means storing the data in two places, and also means the data is out of date for any user that hasn't logged in for a while. Does anyone have any advice or suggestions on how best to handle this kind of scenario?


title: MonoTouch/MonoDroid + C# = trustable?

text: > **Possible Duplicates:**   >  MonoTouch vs Objective-C for iPhone/iPod/iPad development   >  As a C# developer, would you learn Java to develop for Android or use > MonoDroid instead? I'm very curious about the tools named MonoTouch and MonoDroid to create applications for Android, iPhone and iPod by using c# code. Question:   * Are these tools good enough to create applications that will be used in different environments?   * Can these tools replace the orgininal way of creating application? If you create an application for Android, you often use Java to create it.   * How different is it to create a application with Mono for Android compare to creating an application for Windows Mobile Phone?


title: Do Android developers have to pay sales taxes?

text: According to blog post by RetroDreamer Android developers have to pay sales taxes for their App sales in countries with have sales taxes while Apple developers don't as Apple pays the taxes directly. Is this an accurate description? Is so, how do the various people who publish Android apps handle it?


title: Project Closures in Scrum

text: In a typical software development environment, **project closures** mark the end of a project.   1. Project records are completed and archived,    2. resources released,    3. issues and lessons are documented, and    4. a formal dinner/party held for celebration.  Last step is optional, though is very motivating for participants. :-) Contrast this with Scrum. I know that scrum runs on **stories from backlogs**. So, technically, every iteration closes certain stories. So, there are two questions here.   1. For a group that works on **multiple simultaneous projects** , how do project closures fit in?    2. For a project that involves **multiple groups** , how does this concept apply? Or, does project closure term not apply to **T &M projects** at all?


title: Why are interfaces useful?

text: I have been studying and coding in C# for some time now. But still, I can't figure the usefulness of Interfaces. They bring too little to the table. Other than providing the signatures of function, they do nothing. If I can remember the names and signature of the functions which are needed to be implemented, there is no need for them. They are there just to make sure that the said functions(in the interface) are implemented in the inheriting class. C# is a great language, but sometimes it gives you the feeling that first Microsoft creates the problem (not allowing multiple inheritance) and then provides the solution, which is rather a tedious one. That's my understanding which is based on limited coding experience. What's your take on interfaces? How often you make uses of them and what makes you do so?


title: what is the main utility of Interface in real world programming (OOPS)

text: what is the main utility of Interface. we know that we can implement dynamic behavior using interface but i guess it is not only the utility. so i like to know when we have to write interface and when we need to go for abstract class. **show me 5 or 10 most important uses of interface in real life scenario.** another main use is coming to my mind that project manager or team lead will implement basic skeleton through interface and other developer follow it. so please guys show me with sample code few most important use of interface which we can do with abstract class or concrete class. **one guy told me like this way which is not very clear to me** interfaces are defined contracts between classes or structs, consumers can exchange the implementation by a different one as long as the same contract is met that is the method names and signature that compose a specification that classes and structs can work against rather than working against a concrete implementation. The important part about interfaces is to know when to use them and as a matter of fact it's quite simple, when you want two or more unrelated objects to have the same common functionality but not necessarily the same implementation you will want to use interfaces; otherwise, when you have related objects that have a shared functionality and implementation then you may consider to use an abstract class instead of an interface. **this thing is not clear specially** when you want two or more unrelated objects to have the same common functionality but not necessarily the same implementation you will want to use interfaces; otherwise, when you have related objects that have a shared functionality and implementation then you may consider to use an abstract class instead of an interface. it would be nice if anyone explains with sample code when to go for interface & when abstract class. show me few best important area which is always handle with interface with sample code or best interface uses with sample code.thanks


title: Programming to interface in Java

text: What is the real use of interfaces in Java? What is meant by programming to interfaces? I heard these things several times but I don't know what it is and why it is used.


title: Abstract Class, Interface: difference and use

text: > **Possible Duplicate:**   >  When to use abstract classes instead of interfaces and extension methods in > C#? What is the difference between abstract classes and interfaces in java? And under what circumstances should I choose to create an abstract class or an interface. What are the points that I must have in my mind before choosing one of the above?


title: What is the point of an interface?

text: > **Possible Duplicate:**   >  When to use abstract classes instead of interfaces and extension methods in > C#?   >  What other reasons are there to write interfaces rather than abstract > classes? This question sounded a bit trivial to me as well, till I gave a it serious thought myself. What is the point of a Java interface? Is it really Java's answer to multiple inheritance? Despite using interfaces for a while I never got around to think the point of all this. I know what an interface is, but still pondering on the why.


title: What other reasons are there to write interfaces rather than abstract classes?

text: > **Possible Duplicate:**   >  When to use abstract classes instead of interfaces and extension methods in > C#? When I read and looked at codes using Abstract classes, I was able to justify it because it allows you to add common methods for any subclasses extending the abstract class. So for example, if objects behavior is similar, I would use Abstract classes to implement bodyless abstract methods that is required for each object, and simply use non abstract methods already implemented in the abstract class. I can think of a scenario dealing with multiple media file types (avi,mpg,mp4) and you would have common methods for all files, as well as media specific abstract methods that needs to be implemented. However, I am a bit confused as to why you would knowingly create an interface which cannot contain any non-abstract methods. Reading this page, it states that it hides information (you mean the abstract methods?). > Hiding details and providing common interfaces is called encapsulation, > which is an analogy from making an object look like it's covered by a > capsule (the interface in this case). This allows two objects differing in > internal representation but having the common interface interchangeably > usable (called interchangeability). Interfaces also allow to facilitate the > use of data structure and guard the state of the object from invalid inputs > and modification of the structure. So does this mean that any objects which share the common behaviors implemented uniquely can be treated like they are the same category? So for the media file example, does this mean any specific media file type implementing the `interface MediaFile` are to be passed as arguments for a method dealing with such type of objects?               public class ServiceClass {         public ServiceClass(){         //no-args constructor            }              public boolean runService(ICollaborator collaborator){         if("success".equals(collaborator.executeJob())){             return true;         }         else         {             return false;         }     }     }      But can't you do above with an abstract class? Also, isn't the ability of having a non-abstract method better than having none at all for the future when you suddenly need to have an existing method that will apply to all classes extending the abstract class? Or is the difference of using Interface, the ability to protect the implementation of data completely? Once again, I don't see what cases you would use it. Other than that I implement `ActionListener` quiet often to have the `actionPerformed` method.


title: What is Interface in Java programming language?

text: Last week my lecturer was teaching us about interfaces in Java. However, I failed to understand her explanation that well. Does anyone have a good description, or explanation of Java interfaces, and reasons to make use of them?


title: Why do APIs generally consist of interfaces?

text: I am starting out in Java API design and in reading existing code bases, I have found that most APIs consist of interfaces only with their implementations bundled in a different package. Having read that interfaces are generally more problematic to use/maintain than abstract classes, why aren't abstract classes used instead of interfaces?


title: Is using interfaces on internal code a good idea?

text: I'm working on a set of automated tests that we use internally at work. Lately, we've been designing classes that implement interfaces in addition to inheritance. As I understand it, interfaces in Java are used to fulfill a contract. A class that implements an interface must include implementations of any members of that interface. This works really well for building libraries or objects that are meant to be used by outside teams or individuals since it guarantees certain methods will be present. What about code that's entirely kept within a single team in a single location? (Assume this code will stay internal, or else this question changes entirely.) If I can simply go to my VCS history or ask a team-member about changes to code, do I really need to enforce these changes using interfaces? Even if a team is large, you could still develop conventions or tests to verify things. I feel like we're just making more work for ourselves by using interfaces, but maybe there are additional arguments. NOTE: This project is a Java project and will stay that way. Interfaces here are instances of `interface` with all the syntax and rules that apply.


title: Why should I use interfaces if the implementation will mostly stay the same?

text: > **Possible Duplicate:**   >  Why are interfaces useful? In our company we have a service oriented architecture in our asp.net application. We use interfaces for every crap class. Its a huge overhead. The service classes, dataprovider classes etc... they all use interfaces but **practically** we could also go without those interfaces and just use the class type. So why should we do it that complicated and lose lots of productivity?


title: When to use abstract classes instead of interfaces with extension methods in C#?

text: "Abstract class" and "interface" are similar concepts, with interface being the more abstract of the two. One differentiating factor is that abstract classes provide method implementations for derived classes when needed. In C#, however, this differentiating factor has been reduced by the recent introduction of extension methods, which enable implementations to be provided for interface methods. Another differentiating factor is that a class can inherit only one abstract class (i.e., there is no multiple inheritance), but it can implement multiple interfaces. This makes interfaces less restrictive and more flexible. **So, in C#, when should we use abstract classes instead of interfaces with extension methods?** A notable example of the interface + extension method model is LINQ, where query functionality is provided for any type that implements `IEnumerable` via a multitude of extension methods.


title: Understanding interfaces

text: > **Possible Duplicate:**   >  When to use abstract classes instead of interfaces and extension methods in > C#?   >  Why are interfaces useful?   >  What is the point of an interface?   >  What other reasons are there to write interfaces rather than abstract > classes?   >  What is the point of having every service class have an interface?   >  Is it bad habit not using interfaces? I am reading Microsoft Visual C# 2010 Step by Step which I feel it is a very good book on introducing you to the C# language. I have just finished reading a chapter on interfaces and although I understood the syntax of creating and using interfaces I have trouble of understanding the point on why should I use them? Correct me If I am wrong but in an interface you can only declare methods names and parameters.The body of the method should be declared in the class that inherits the interface. So in this case why should I declare an interface if I am going to declare the entire method in the class that inherits that interface? What is the point? Does this have something to do with the fact that a class can inherit multiple interfaces?


title: How to synchronize web page refresh with file upload from windows application?

text: I have a rather simple app in .net which uploads images in fixed intervals in an ftp server. The file name is specific. I need to have a web page that refreshes **but** i want this to happen only when the upload finishes. How i find a way to determine that the upload has finished? And if the solution has to do with renaming and deleting temp files, should i do this from the windows app or server side? Thanks update: What if i could find a way to check if a filename is a **valid** jpg? I mean if the transfer is not over this check should return false..ideas?


title: Python lower_case_with_underscores style convention: underscores not popular?

text: PEP8 recommends using > lowercase, with words separated by underscores as necessary to improve > readability for variable and function names. I've seen this interpreted as `lower_case_with_underscores` by most people, although in practice and in Python's native methods it seems like `lowercasewithoutunderscores` is more popular. It seems like following PEP8 strictly would be awkward since it seems to suggest mixing both `lower_case_with_underscores` and `lowercasewithoutunderscores`, which would be inconsistent. What is your interpretation of PEP8's variable names, and what do you actually use in practice? (Personally, I like `lowerCamelCase` as a compromise between readability and ease of typing.)


I was wondering what that term even meant. Is it something to do with one's amount of knowledge about the Ruby language or just the plain idea of using it. When can one call themselves a "Rubyist"?


title: GitHub etiquette for duplicating a repo to change functionality

text: I've found a GitHub project I'd like to add some features to. After contacting the maintainer, the changes aren't in line with the direction he's going but he's interested to see what I do with it. What is the GitHub etiquette for using one repo as a base for another project that almost certainly won't ever be merged back into the original? Instead of forking, my instinct is to create a brand new repo and manually copy the current state of the original code into it. Then, in the documentation, give credit and a link to the original author/repo for the starting point. Is that acceptable, or is there some other standard approach?


title: I'm trying to create a visual representation of something, but I don't know what words to use, so I'll try to describe it

text: My project team is making a site that will use reddit style voting to track users' opinions on various issues, and use the data to create a "heat map". I say heat map in quotes because I'm not sure that it's the correct term - I don't have the math to express it properly. The idea is you'll be able to see, on a 2 dimensional graph, how your opinons compare to those of other voters in your municipality, and to politicians currently running for office. This will help voters make more informed decisions about voting. I'm not sure how to code this or even what to start googling for. Can anyone suggest a direction? ** I'll change the title to something more useful when I have more information, sorry


title: How to overcome the fear of building a web application with a recurring payment system?

text: I'm a Ruby on Rails developer. I'd like to create a web application. I will let users get a payed subscription to use the product. So I will need a recurring billing system (e.g. via paypal). But there is the fear to fail and make some bad mistakes, because I will handle money from other people.... regardless following the instructions of e.g. Ryan Bates on Railscasts how to implement such a recurring payment system. What is your advice to overcome this fear of building such a product? What are the risks I need to calculate when designing such a system?


title: What do you do to remain productive when working on your own?

text: I find working in isolation, on a piece of code that won't be seen by anyone else for weeks, draining. I'm looking for ideas to try to keep myself productive and motivated. What do you do to remain motivated and productive, when given a long term programming task, and working on your own (for example, from home, without any team-mates or coworkers)?


title: Marking services for secure handling; Annotation or inheritance?

text: We have a lot of services, some that demand some security, some that don't. We want an easy way of telling, in code, if a service will be secure or not. What would be the better way: Annotation or inheritance?               public class SomeServiceImplementation : BaseSecureService, ISomeService      or               [SecureService]     public class SomeServiceImplementaion : ISomeService


title: Is this a ridiculous way to structure a DB schema, or am I completely missing something?

text: I have done a fair bit of work with relational databases, and think I understand the basic concepts of good schema design pretty well. I recently was tasked with taking over a project where the DB was designed by a highly- paid consultant. Please let me know if my gut intinct - "WTF??!?" - is warranted, or is this guy such a genius that he's operating out of my realm? DB in question is an in-house app used to enter requests from employees. Just looking at a small section of it, you have information on the users, and information on the request being made. I would design this like so: ### User table:               UserID (primary Key, indexed, no dupes)     FirstName     LastName     Department      ### Request table               RequestID (primary Key, indexed, no dupes)     <...> various data fields containing request details     UserID -- foreign key associated with User table      Simple, right? Consultant designed it like this (with sample data): ### UsersTable               UserID  FirstName   LastName     234     John        Doe     516     Jane        Doe     123     Foo         Bar      ### DepartmentsTable               DepartmentID   Name     1              Sales     2              HR     3              IT      ### UserDepartmentTable               UserDepartmentID   UserID   Department     1                  234      2     2                  516      2     3                  123      1      ### RequestTable               RequestID   UserID   <...>     1           516      blah     2           516      blah     3           234      blah      The entire database is constructed like this, with every piece of data encapsulated in its own table, with numeric IDs linking everything together. Apparently the consultant had read about OLAP and wanted the 'speed of integer lookups' He also has a large number of stored procedures to cross reference all of these tables. Is this valid design for a small to mid-sized SQL DB? Thanks for comments/answers...


title: Is it a good idea to use CouchDB?

text: Is it a good idea to use CouchDB for a web application that is going to be platform agnostic (from tablet to PC):   * The app is a big form which I need to be able to modify at will.    * I also need to scan the results to retrieve the data to send some file to help the client.   * I need to be able to upload the results to a master server.   * I want to mainly use the app offline and online at will.  The data is questions with answers and comments linked to them. At the end a percentage is generated for the user and depending on the result, a call to another application will be made to "send" information to the user depending on its results. The application needs to be offline because we don't know if the user is connected to the internet at the time they answer the questions. The data needs to be the same on all platforms (replication is a given). I cannot rely on the browser even if the app is going to be built with HTML5, CSS and JavaScript. Is it possible with CouchDB and is it a too big mandate for only one person? If there are not enough details, ask and I will explain more thoroughly. **EDIT:** After all your answers here is what i have concluded.   * I am gonna use SQLite and sync it with our sql databases.   * NoSQL is not made for the kind of app i am working on.   * Using what you know is sometimes the way to go    * If you dont know how to use the technology and intend to use it for a huge project your coding alone. dont.


title: Do abstractions have to reduce code readability?

text: A good developer I work with told me recently about some difficulty he had in implementing a feature in some code we had inherited; he said the problem was that the code was difficult to follow. From that, I looked deeper into the product and realised how difficult it was to see the code path. It used so many interfaces and abstract layers, that trying to understand where things began and ended was quite difficult. It got me thinking about the times I had looked at past projects (before I was so aware of clean code principles) and found it extremely difficult to get around in the project, mainly because my code navigation tools would always land me at an interface. It would take a lot of extra effort to find the concrete implementation or where something was wired up in some plugin type architecture. I know some developers strictly turn down dependency injection containers for this very reason. It confuses the path of the software so much that the difficulty of code navigation is exponentially increased. My question is: when a framework or pattern introduces so much overhead like this, is it worth it? Is it a symptom of a poorly implemented pattern? I guess a developer should look to the bigger picture of what that abstractions brings to the project to help them get through the frustration. Usually though, it's difficult to make them see that big picture. I know I've failed to sell the needs of IOC and DI with TDD. For those developers, use of those tools just cramps code readability far too much.


title: Which back-end web programming language to use

text: I have a project where I will be collaborating to build a fairly simple site with some database access. I will be doing the back-end work, and my colleague will be doing the web design. The problem is that my colleague has only worked with PHP developers and I have a lot more experience in Perl. The options would be to either learn PHP while doing the project or for my colleague to learn how to design around Perl. (I guess a third option would be to decline the project because this obstacle is just too insurmountable). If the answer is to use Perl, the next question is which templating module would be easiest for my PHP-aware web designer colleague to adapt to. HTML::Mason? HTML::Template? Something else?


title: Design Document From Code

text: I am not much familiar with documenting/System designing stuff. I have to maintain an application written in C# - working as windows service.   However there is no documentation for this system which makes it really pathetic to find where some problem (conceptually) occurred. I would like to know the best way to design/document it (using current code) manually or preferably automatically so that I can identify the exact problems. Like I feel as if sequence diagram won't much help probably.   Also, please guide me if I am taking it on wrong side?


title: Quality Assurance activities

text: > **Possible Duplicate:**   >  Verification of requirements question Having asked but deleted the question as it was a bit misunderstood. If Quality Control is the actual testing, **what are the commonest true quality assurance activities?** I have read that verification (reviews, inspections..) but it does not make much sense to me as it looks more like quality control as mentioned here:   _DEPARTMENT OF HEALTH AND HUMAN SERVICES ENTERPRISE PERFORMANCE LIFE CYCLE FRAMEWORK Practices guide_ > Verification - “Are we building the product right?” **Verification is a > quality control technique** that is used to evaluate the system or its > components to determine whether or not the project’s products satisfy > defined requirements. During verification, the project’s processes are > reviewed and examined by members of the IV&V team with the goal of > preventing omissions, spotting problems, and ensuring the product is being > developed correctly.   >  Some Verification activities may include items such as: • Verification of > requirement against defined specifications • Verification of design against > defined specifications • Verification of product code against defined > standards • Verification of terms, conditions, payment, etc., against > contracts And the opposite ( _project management knowledge scope_ \- google result) **Verification is a quality assurance process or technique applied by ...**


title: Android development using C and C++

text: I am a C, C++ developer. I am interested in mobile development. I want to know how can I develop Android apps using C and C++, I have read that they are providing a kit for C, C++ developers but it does not have all functions as of Java kit. Should I go for C/C++ development kit or it's better to learn java as they may not provide all the functionality in future?


title: Are there some types of software that cannot be developed by all major programming languages?

text: I'd like to know if some of the major programming languages can absolutely not be used to create some very specific types of software. By major programming language I mean the likes of C++, C#, Java, Ruby, Python. By "cannot be developed" I mean cannot be developed or it is unrealistic to do it due to performance, difficulty of implementation, etc. I've always thought that any programming language could be used to solve any problem but lately I've been thinking that some languages are unsuitable for some projects. If you can provide examples of such applications, it would be appreciated. Thanks.


title: How does "new message" notification work?

text: I'm interested to know the implementation of the 'new message' in gmail for example. I know that ajax is used, but what else it is used on the server and client side. Can you explain me the scenario? Gmail is just a sample to sustain my question. I'm interested about the cheapest solution which allow to display new content in asynchronous manner without a user triggered event. If you know a resource which explains the optimal way of implementing such app I will appreciated. TY


title: Technique to deal with occasionally blocking json api?

text: I have a web app that occasionally (after some idleness) will block a very simple request for small chunks of data (30~50 kb) up to 20 or so seconds. Assuming I can't refactor or modify the API, is there some pattern in javascript or jquery to accommodate a situation like this? I'm thinking to set a timeout for 5 seconds or so for the api call and retry the ajax request -- via jquery's $.ajax() with the timeout argument. I imagine this could be the equivalent of the user refreshing a slow-loading page. Thanks for your thoughts.


title: What are some good office-layout guidelines for a small development team?

text: Our office is moving soon and we have the opportunity to redesign our office space. We have five developers and a couple of testers, working with a project manager, and a business analyst. I'd like your ideas for an ideal office layout for a a small development team like ours.


title: Generic term for "objects" vs "fundamental types"?

text: What are the exact terms to call **data types with a logic structure** (like C structures, C++ or Java objects) versus **fundamental data types** (like numeric types, characters, booleans...) independently of any language or paradigm. (I am searching for abstract/academic computer science words).


title: Could the trivium be used to successfully teach programming languages?

text: The trivium is a systematic method of critical thinking for deriving certainty from any information which is comprised of:   * grammar    * logic    * rhetoric Joseph, Sister Miriam (2002). in _The Trivium: The Liberal Arts of Logic, Grammar, and Rhetoric. Paul Dry Books, Inc._ shortly describe this stages: > Grammar is concerned with the thing as-it-is-symbolized, Logic is concerned > with the thing as-it-is-known, and Rhetoric is concerned with the thing as- > it-is-communicated When I learned about the trivium I realized that would be the best way to approach teaching programming languages. Adapted to programming languages this would be the stages:   * in the grammar stage there would be the learning phase where writing any program, playing with all the all variants of syntax, simple, data structures, using all the keywords, datatypes, making simple programs, would be the goal.   * in the logic stage there will be teaching algorithms, complex conditionals, as a learning goal    * in the rhetoric stage there could be teaching programming paradigms, procedural programming, OOP, collaboration and versioning tools (git) etc. What would be the shortcomings of the trivium method applied to programming languages, what would be the learning subjects who could not be integrated with the trivium method, and would the trivium stages order(grammar first, logic second, etc) apply well to programming learning?


title: My github pull request was merged, what's the convention at this stage?

text: I forked a project on Github, made a small change and sent a pull request to the original maintainer, who has pulled it in. Now the last commit there is `Merged pull request #11 from my_username/master`. This is the first time I'm doing this, so I'm not sure what the etiquette now is: I did a `git pull upstream master` and then `git push origin master`, and now the last commit on my own repository reads `Merged pull request #11 from my_username/master` which feels pretty weird to me. Is this the way people usually do it, is there anything I need to do to "clean up the history" or something? Note: since this was a tiny documentation change, I hadn't created any branches, I just made the change in my `master` branch and sent the pull req. So there's no cleanup to be done in that part.


title: Is it really that hard to find good developers?

text: There was a topic about job marker few days ago, and urban legends about this topic have been floating around as well. So, what's your experience? Have you tried hiring programmers (it's probably a good idea to mention the sector - web/database/embedded/general, and a continent)? And what are your experiences? Do companies receive 500+ CVs a day? No-one applies? People who apply are bad at things? What are the main reasons why candidates are found "not good enough"?


title: Good open source projects to master Python concurrency

text: Concurrent programming in Python is very colorful (and confusing too). There's just too many options with each having it's pros and cons...   * Thread based (`threading` module)   * Process based ( `multiprocessing` module)   * Co-routines (`greenlet`, `gevent`, `eventlet`)   * Async (`Twisted`, `Tornado`)   * Inter-process communication (`subprocess` module)   * Message queue based (`ØMQ`, `PyCom`, `mpi4py`)   * Others (`Pyro`, `execnet`, `Parallel Python`) I know some of these and can write programs using them. But, I just don't feel I know them pretty well -- I can't decide what to use when. I don't know how to put these into perspective. So, my simple question is -- what are some open source projects that employ these techniques so that I can see them in action in real program.


title: OO Design principle name?

text: I think I remember reading somewhere that one of the principles of good OO design is to write methods which take the least derived type possible, but return the most derived type possible? First, is there such a principle and second, what name would it go by? I'm looking for the name so that when I mentor other developers I can refer them to it.


title: How to advocate Stack Overflow at work

text: I am thinking of doing a short presentation at work about using Stack Overflow as a resource for your day job. What is your experience doing this? Would you deem it a valid resource to tell your colleagues about it or is it similar to telling them about Google as a resource? Is there a better way of doing it? I was leaning toward asking questions side of Stack Overflow rather than answering them to avoid you-shouldn't-be-doing-this-on-work-time argument. * * * Just as a follow up. Originally I didn't want to make the question too specific to my own case. My presentation will only be a quick four minute talk, which I will repeat over an hour to different groups. I may ask a question before the talk on Stack Overflow and refer to it during the presentation. Hopefully I will get some activity during the hour. I am also going to talk briefly about some of the other Stack Exchange sites that would fit the audience as they are not all developers. I think Super User, Server Fault and Programmers should work well. I will not be doing the presentation for another couple of months as it has been rescheduled, but I will update on how I got on.


title: Python as a first language?

text: I have just started working in Information Security World. I want to learn the Python language for creating my own automated tool for Fuzzing, SQL-Injection etc. My question is I don't know much about C language (only basic knowledge) but I want to learn directly Python Language so is it good? I have seen there is lots of difference between Python and C (obviously) and for Information Security field Python = GOD so I want to know learning Python need any experience on C language? If not so can I start learning Python directly?


title: Make audible Ding! sound, or growl notification, when `rake test` finishes!

text: I lose a ton of productivity by getting distracted while waiting for my tests to run. Usually, I'll start to look at something while they're loading --- and 15-20 minutes later I realize my tests are long done, and I've spent 10 minutes reading online. Make a small change... rerun tests ... another 10-15 minutes wasted! How can I make my computer make some kind of alert (Sound or growl notification) when my tests finish, so I can snap back to what I was doing??


title: In what order should I read these books?

text: This question is not a duplicate - I'm not asking about the best books. Rather, I'm asking for the best order in which to study. I'm new to programming but I finished a very, very simple book (Beginning C# 3.0: An Introduction to Object Oriented Programming) and wrote some simple programs. These are the books I plan to read from here: Pro C# 2010 and the .NET 4 Platform C# 4.0 in a Nutshell: The Definitive Reference CLR via C# C# in Depth, Second Edition What would be the best order in which to study them?


title: is it safe to use jQuery and MooTools together?

text: I just need to know is it safe to use jQuery and MooTools Together in one web framework? I am not trying create application using both of them, but I am in a situation where I need to modify mootool based application framework, so I am used to jquery, I don't want to waste my time learning mootools and I think jquery is better than the mootools in many contexts like number of applications, plugins etc. so questions are   1. is it safe to use mootools and jquery in one framework?   2. will there be cross browser issues?   3. how robust the application will be when using both?


title: Two interviews: Advice on replying to lesser of the two if awaiting result of the preferred one

text: I recently gave two interviews (Say company A and B) and am inclined to get into company A more than B. The hiring manager of A might get a little late in replying. I do not want to lose B if I don't get into A. I want to know if I get a positive reply from company B before A, is there a polite way to say that I am waiting on one other result? Or can I buy a week or so? How do I convey this? Thanks in advance.


title: Does KISS encourage tools and frameworks that expose complex leaky abstraction layers?

text: Tools and frameworks make complex tasks simple. This seems like something that would be supported by KISS(keep it simple stupid). Tools and frameworks also have the potential to introduce leaky layers of abstraction, where the complexity of the issues are far more problematic than anything you would have written yourself. I am not interested in the effectiveness of tools and frameworks, since that is more of a religious opinion, and can be kept private. What I am interested in is whether or not tools and frameworks are favored by KISS. Obviously some layers of abstraction are accepted by just about everyone, but there are plenty of examples of edge cases where it is harder to tell. For example: For a web service in .Net, would KISS favor a basic WCF service (super easy to create; fairly difficult understand/see what is actually going on under the hood) or a basic REST service (more challenging to create; easier to understand/see what is actually going on under the hood)? Note: There are plenty more examples of this, so feel free to suggest more appropriate ones.


title: When should you rewrite?

text: > **Possible Duplicate:**   >  When is a BIG Rewrite the answer? In Joel Spolsky's famous (or infamous) article Thins You Should Never Do, Part I, he makes the case that doing a rewrite is always a wrong move because:   1. It automatically puts you behind (your competitors/schedule/etc.)   2. The code probably isn't as bad as the programmers believe (anything someone else wrote is always a mess, although some are bigger messes than others - and even then)   3. It's probably easier/quicker/cheaper to fix what's truly wrong with it than to rewrite from scratch.   4. In rewriting from scratch, you are probably going to re-introduce bugs that were fixed in previous versions the original code. Instead, he recommends fixing what's wrong with the code. I assume this is a good summary of his post, and I'll postulate that it is generally true. I'm trying to collect a set of rules/guideline for my team, and one of them (based on Joel's article) is               We don’t re-write ... ever!      - But we can refactor large portions of the code.       (this exception takes care of ugly/problematic code issues)      One question that has cropped up is "What about when technology changes and you can no longer get support for older versions?". This is what I think of as the Sisyphean Upgrade path. E.g., I recall when Oracle moved from SQL*Forms 2.x/3.x through to Forms 6i and beyond, Forms that were originality developed in the old .inp format were no longer supported with the current version of Oracle and Oracle Forms. So you had a choice of sticking with an unsupported database with unsupported tools or rewriting the Forms from scratch (or converted with 3rd party tools and then gone over with a fine toothed comb). Which I will call porting, particularly when you are doing a faithful line by line/function by function translation into the new tech and not adding any functionality. The rule then became:               We don’t re-write ... ever!     - But we can refactor large portions of the code.     - And we can port the code to a new platform when we *truly* have no other        choice.      (and by truly I mean, you can't even buy your way out of the problem for 2x the cost of porting it) Are there any other exceptions that I've missed?


title: How can I convince management to deal with technical debt?

text: This is a question that I often ask myself when working with developers. I've worked at four companies so far and I've become aware of a lack of attention to keeping code clean and dealing with technical debt that hinders future progress in a software app. For example, the first company I worked for had written a database from scratch rather than use something like MySQL and that created hell for the team when refactoring or extending the application. I've always tried to be honest and clear with my manager when he discusses projections, but management doesn't seem interested in fixing what's already there and it's horrible to see the impact it has on team morale. What are your thoughts on the best way to tackle this problem? What I've seen is people packing up and leaving. The company then becomes a revolving door with developers coming in and out and making the code worse. How do you communicate this to management to get them interested in sorting out technical debt?


title: I've inherited 200K lines of spaghetti code -- what now?

text: I hope this isn't too general of a question; I could really use some seasoned advice. I am newly employed as the sole "SW Engineer" in a fairly small shop of scientists who have spent the last 10-20 years cobbling together a vast code base. (It was written in a virtually obsolete language: _G2_ \-- think Pascal with graphics). The program itself is a physical model of a complex chemical processing plant; the team that wrote it have incredibly deep domain knowledge but little or no formal training in programming fundamentals. They've recently learned some hard lessons about the consequences of non-existant configuration management. Their maintenance efforts are also greatly hampered by the vast accumulation of undocumented "sludge" in the code itself. I will spare you the "politics" of the situation (there's _always_ politics!), but suffice to say, there is not a consensus of opinion about what is needed for the path ahead. They have asked me to begin presenting to the team some of the principles of modern software development. They want me to introduce some of the industry- standard practices and strategies regarding coding conventions, lifecycle management, high-level design patterns, and source control. Frankly, it's a fairly daunting task and I'm not sure where to begin. Initially, I'm inclined to tutor them in some of the central concepts of _The Pragmatic Programmer_, or Fowler's _Refactoring_ ("Code Smells", etc). I also hope to introduce a number of Agile methodologies. But ultimately, to be effective, I think I'm going to need to hone in on 5-7 core fundamentals; in other words, what are the most important principles or practices that they can realistically start implementing that will give them the most "bang for the buck". So that's my question: What would _you_ include in your list of the most effective strategies to help straighten out the spaghetti (and prevent it in the future)?


title: Reengineering the project from scratch

text: > **Possible Duplicate:**   >  When do you rebuild an application or keep on fixing the existing one I am currently working on a project that has been in development for the last few years used throughout the organization but the way the project has been coded the maintainability of it is completely shot. Reading the code presents with pages and pages of Anti-Patterns and trying to identify the path of a business workflow takes on occasion days. At this point I would probably classify the software in its current state as "Working by accident" rather then as intended. So I am looking for some wisdom as to the following: At what point would you consider simply dumping the project into an abandonware pile and starting from scratch? P.S. I understand that in a lot of cases organization would consider it cheaper to maintain the existing project.


title: How would you know if you've written readable and easily maintainable code?

text: How would one know if the code he has created is easily maintainable and readable? Of course in your point of view (the one who actually wrote the code) your code is readable and maintainable, but we should be true to ourselves here. How would we know if we've written pretty messy and unmaintainable code? Are there any constructs or guidelines to know if we have developed a messy piece of software?


title: Self-Evaluation: How do I know if I actually have a "good grasp" of OOP?

text: If I skip the back story and any thoughts I have on this topic, there's really only one question left to ask: **How can I find out if I have a "good grasp" on OOP?** (I am specifically using PHP, but it probably won't matter...) Right now I kind of think of classes as a collection of functions with some global-ish variables accessible by all those functions. This helps to reuse code, keep files short and the namespace clean. Some of you mentioned inheritance: To me that again just means that I can extend an existing class with more functions and more global-ish variables. It's like an add on to my existing class. And the same benefits come into place: reuse code, keep files short. I have a ominous feeling that I'll be disillusioned here in a minute...


title: How to explain to a non-technical person why the task will take much longer than they think?

text: Almost every developer has to answer questions from business side like:   Why is going to take 2 days to add this simple contact form? When a developer estimates this task, they may divide it into steps:   * make some changes to the Database   * optimize DB changes for speed    * add front end HTML   * write server side code   * add validation   * add client side javascript    * use unit tests   * make sure SEO set-up is working   * implement email confirmation   * refactor and optimize the code for speed   * ... These maybe hard to explain to a non-technical person, who basically sees the whole task as just putting together some HTML and creating a table to store the data. To them it could be 2 hours MAX. So is there a better way to explain why the estimate is high to a non- developer?


title: How to educate business managers on the complexity of adding new features?

text: We maintain a web application for a client who demands that new features be added at a breakneck pace. We've done our best to keep up with their demands, and as a result the code base has grown exponentially. There are now so many modules, subsystems, controllers, class libraries, unit tests, APIs, etc. that it's starting to take more time to work through all of the complexity each time we add a new feature. We've also had to pull additional people in on the project to take over things like QA and staging, so the lead developers can focus on developing. Unfortunately, the client is becoming angry that the cost for each new feature is going up. They seem to expect that we can add new features _ad infinitum_ and the cost of each feature will remain linear. I have repeatedly tried to explain to them that it doesn't work that way - that the code base expands in a fractal manner as all these features are added. I've explained that the best way to keep the cost down is to be judicious about which new features are really needed. But, they either don't understand, or they think I'm bullshitting them. They just sort of roll their eyes and get angry. They're all completely non-technical, and have no idea what does into writing software. Is there a way that I can explain this using business language, that might help them understand better? Are there any visualizations out there, that illustrate the growth of a code base over time? Any other suggestions on dealing with this client?