Does this violate the using exceptions for flow control "rule"?

I plan to make use of this interface in a plug-in architecture.               /// <summary>     /// Generic interface allowing you to react to an event.     /// You can block the event or just use it for notification.     /// </summary>     /// <typeparam name="T"></typeparam>     public interface IEventObserver<in T> where T : class     {         /// <summary>         /// Throw an exception in here if you want to prevent the event firing.         /// </summary>         /// <param name="o"></param>         void CanFireEvent(T o);              /// <summary>         /// This is only called if no handler threw an event in the CanFire.         /// </summary>         /// <param name="o"></param>         void OnBeforeEvent(T o);              /// <summary>         /// This is called after the event has happened.         /// </summary>         /// <param name="o"></param>         void OnAfterEvent(T o);     }      Example usage:               public interface ISendMessageObserver : IEventObserver<SendMessageEventArgs>     {     }      A plug-in can then implement `ISendMessageObserver` and prevent message sending by throwing an exception in the `CanFireEvent` method. However, I know that exceptions should not be used for normal program flow control, yet it is normal and expected for plugins here to stop the flow. I went for this because I'd like the plugin to provide a reason for blocking the event that can be logged or presented to the user. I could change `CanFireEvent` to:               bool CanFireEvent(T o, ref message);      or:               SomeTypeContainingAbortReason CanFireEvent(T o);      But both of those don't smell ideal either. So what do people think, exceptions for flow control OK in this instance? **Edit** I've separated the `CanFire` into it's own interface and renamed it as `PreviewEvent`.               /// <summary>     /// Generic interface allowing you to react to and block an event.     /// </summary>     /// <typeparam name="TArgs"></typeparam>     /// <typeparam name="TBlock"></typeparam>     public interface IEventPreviewer<in TArgs, out TBlock>         where TArgs : class         where TBlock : class, IEventBlock     {         /// <summary>         /// Return an IEventBlock to prevent the event from firing.         /// </summary>         /// <param name="args"></param>         TBlock PreviewEvent(TArgs args);     }          public interface IEventBlock     {         string BlockReason { get; }     }


Which is better: many class definitions in the same file or every class definition in a separate file?

Which is better: many class definitions in same file or every class definition in separate file? **Examples:** 1) Many classes in same file. Say, `myManyClasses.cs`:               namespace myPack     {        class myClass1()        {        }        class myClass2()        {        }        class myClass3()        {        }       .        .        .     }      2) Every class in separate file: _myClass1.cs_               namespace myPack     {        class myClass1()        {        }     }      _myClass2.cs_                namespace myPack      {        class myClass2()        {        }       }      **. . .**


Where to read from file?

In Java: I have a class Students. I would like to read a list of students from a file. Which one is more elegant:   1. Reading and constructing the list in main(), and creating a Student object with the new list passed to the constructor   2. Passing a FileReader to the constructor, who does the reading?   3. Something else?


Python reading from stdin while doing other tasks

I am trying to write a system log parser. It will receive messages from the FreeBsd syslog daemon through stdin. It will use those messages to determine if an ip should be banned or not. The problem I have is that after x seconds the ban should be removed, but if I won't get any input from stdin, my program will just block waiting for it. So in the mean time I can't do anything. I fixed it using threads, but isn't there a better way to do it? For example something like this:               while true:         while <data in stdin>:             handleData              doSomeStuff()      So as long nothing comes in from stdin I want to execute doSomeStuff, and if there is data handle it.


How do I decide what type of programmer I want to be?

I've been working at my current work for some time, and I'm considering a bit of a change of careers. I'm trying to decide what it is exactly that I want to do, and I'm really just not sure. I'm not wanting a solution for my particular case, but what I'd like to know are some generalities of things I can look for. Here are some positions that I'm considering, and what my definitions are (I'm probably calling them something other than what is standard, but hopefully this will do for now). I'm looking for quizzes, articles, explanations, or anything that can help me figure this out.   * Manager - Managing programmers in some sense, mostly in making sure they are kept working.   * Coder - A person who is told to make a program do XYZ, and makes it do that. Doesn't have to model anything, or come up with formulas.   * Algorithm Designer - A person who comes up with a way to make software do something, but doesn't necessarily code that program, at least, not in it's final form.   * QA - A person who tests code for bugs, preferably with the code in hand.   * Architect - This person figures out how all of the pieces fit together, is a technical manager of sorts.    * Maintainer - This person takes someone else's existing code, and makes sure it is fixed when issues arise. Also of some note is figuring out what industry I want to work in. Feel free to add any of your own categories.


What do developers want to learn at their next startup?

As a developer, i know how much I like learning new stuff. Now that I'm hiring developers for my startup, I know I can't compete with Google's zillion-dollar bonuses and fancy cafeterias, but we are rich with opportunities for curious people to learn. I want to set things up to support that. So if you're a developer likely to join a startup, what do you want to learn? Product things? Business things? User research, design, or tech ops things? Or if it's more technical learning you're after, do you want to go deeper in what you know (e.g., back end learning back end) or cross-train (e.g., front end learning back end)? Or is there something else entirely?


Are people succeeding with OrientDB?

OrientDB looks very attractive from a functionality+license standpoint. I haven't been able to google up much in the way of reports by people who have used it. Can anyone cite particularly notable successes or failures?


Monitoring C++ applications

We're implementing a new centralized monitoring solution (Zenoss). Incorporating servers, networking, and Java programs is straightforward with SNMP and JMX. The question, however, is what are the best practices for monitoring and managing custom C++ applications in large, heterogenous (Solaris x86, RHEL Linux, Windows) environments? Possibilities I see are:   1. Net SNMP     * Advantages       1. single, central daemon on each server       2. well-known standard       3. easy integration into monitoring solutions       4. we run Net SNMP daemons on our servers already     * Disadvantages:       1. complex implementation (MIBs, Net SNMP library)       2. new technology to introduce for the C++ developers   2. rsyslog     * Advantages       1. single, central daemon on each server       2. well-known standard       3. unknown integration into monitoring solutions (I know they can do alerts based on text, but how well would it work for sending telemetry like memory usage, queue depths, thread capacity, etc)       4. simple implementation     * Disadvantages:       1. possible integration issues       2. somewhat new technology for C++ developers       3. possible porting issues if we switch monitoring vendors       4. probably involves coming up with an ad-hoc communication protocol (or using RFC5424 structured data; I don't know if Zenoss supports that without custom Zenpack coding)   3. Embedded JMX (embed a JVM and use JNI)     * Advantages       1. consistent management interface for both Java and C++       2. well-known standard       3. easy integration into monitoring solutions       4. somewhat simple implementation (we already do this today for other purposes)     * Disadvantages:       1. complexity (JNI, thunking layer between native C++ and Java, basically writing the management code twice)       2. possible stability problems       3. requires a JVM in each process, using considerably more memory       4. JMX is new technology for C++ developers       5. each process has it's own JMX port (we run a lot of processes on each machine)   4. Local JMX daemon, processes connect to it     * Advantages       1. single, central daemon on each server       2. consistent management interface for both Java and C++       3. well-known standard       4. easy integration into monitoring solutions     * Disadvantages:       1. complexity (basically writing the management code twice)       2. need to find or write such a daemon       3. need a protocol between the JMX daemon and the C++ process       4. JMX is new technology for C++ developers   5. CodeMesh JunC++ion     * Advantages       1. consistent management interface for both Java and C++       2. well-known standard       3. easy integration into monitoring solutions       4. single, central daemon on each server when run in shared JVM mode       5. somewhat simple implementation (requires code generation)     * Disadvantages:       1. complexity (code generation, requires a GUI and several rounds of tweaking to produce the proxied code)       2. possible JNI stability problems       3. requires a JVM in each process, using considerably more memory (in embedded mode)       4. Does not support Solaris x86 (deal breaker)       5. Even if it did support Solaris x86, there are possible compiler compatibility issues (we use an odd combination of STLPort and Forte on Solaris       6. each process has it's own JMX port when run in embedded mode (we run a lot of processes on each machine)       7. possibly precludes a shared JMX server for non-C++ processes (?) Is there some reasonably standardized, simple solution I'm missing? Given no other reasonable solutions, which of these solutions is typically used for custom C++ programs? My gut feel is that Net SNMP is how people do this, but I'd like other's input and experience before I make a decision.


Does it still make sense to think about effective code on micro scale in C++?

Early in my programming career I was in love with pointer twiddling, lean code, doing everything with as little layers of abstraction as possible and so on. The code was very C like I would say, close to metal and clever. Time has passed, I have a lot more experience, and I'm noticing my attitude towards the code has changed. And with changed, I mean, I don't want to bother about everyday stuff anymore, unless it's super easy to do. If there is a string concatenation, I will never choose raw pointers deliberately. If I need to concatenate stuff, I might add a quick guess reserve for an STL container, but I don't want to bother with preallocated buffers, C like APIs, caches, avoiding hitting the disk, or trashing. I know realloc might happen from time to time, including all the heap locks, extra copying and so on, but I don't even bother anymore. Maybe, it is because I have spent some time early in my career where I thought of a clean and beautiful schemes with worker threads that process large amount of trivial data, only to find out later that the whole unoptimized realloc+copy+realloc+copy+realloc+copy+5 layers of wrappers doesn't even register in profiler. Maybe it's because I've seen how compilers sometimes do magic. However, such trivial things do add up. When all your code base uses higher order constructs, it has chances that there will be some realloc all over the place, or cold disk hits, that can cause a general perception of a slow application. Sort of like WTL vs MFC. Or how you instantly know that the application is written in Java when you launch it. But is it really? Is there any comparisons of software that's using only very lean and smart code vs software that uses generic containers all over the place? Would you even feel a difference if the string allocation throughout the program would be using prereserves and smart moves vs lazily calling string.append in every place where there is a need for such functionality? Do you try to implement mitigation solutions for such simple, well known things that are cheap to execute anyway? Can software turn into bloatware just because extra caution is not applied to every line of code?


How to pronounce CRUD?

I was talking to a co-worker and was talking of how Database operations usually can be broken down into one of the elements of CRUD- Create, read, update and delete. That's when I realised that I do not know how to pronounce CRUD. So is there a definite, well accepted way to pronounce CRUD?


How can I get programmers to work together better on shared code with tests

We keep repeating "you have to pull first" (this is git and github by the way). Then you code a little, then get your tests to pass, then commit, then pull and push again. We give tutorial links, try firm / hard. The latest changes broke 2 dozen tests. We document everything. What other things can we do to help folks. We require passing tests. Right now we are tempted to rollback all of todays changes which wouldn't be popular. I'm not a big fan of that harsh an approach to management but perhaps a 'final' warning that we will do that next time is now required. Failing that it's clear they need to fix broken tests, right? We fixed them last time so that didn't 'take'...


What are some of the required tools to gauge how large and complex a product is going to be?

Let's say I want to start developing a project (for the sake of example, let's use facebook, ultimate-guitar, and all recipes or AutoCAD, outlook, angry birds). All of these apps are successful and vary in the degree of "depth" and complexity. As a starting developer most of these apps and especially the web apps seem simplistic to build and design especially if you're using a good framework. How can I gauge, estimate and forecast the complexity of a project?


Should jQuery DOM manipulation be avoided in favor of JavaScript template engines?

From what I can tell, most developers will use heavy jQuery DOM manipulation tactics to deliver their updated AJAX views. Once things get out of hand, they may consider refactoring using template engines such as Mustache.js. Is this a valid assessment of a natural progression to use a template engine? When I begin a new AJAX heavy project, is the best practice to use a template engine or is jQuery DOM manipulation good enough? I have yet to find any negatives with using a template engine. The maintainability, efficiency and simplicity seem to be the redeeming qualities. Please advise me on whether JavaScript template engines should be used or not by default.


Confusion with gpl license

I am really confused about software linceses, I've read a lot of articles but I can't find an answer to my question, which is: Can I develop and sell applications that uses libraries under gpl license? Like for instance, I want to use agsXMPP library in a windows phone app, and sell it in the market, so is it legal?


Export to Excel - threading

I am working on an ASP.NET application. One requirement by the users is they are capable of exporting to Excel of some UIs. I have worked on them using the Infragistics library, and I have supplied them with the exports they want. However, some of the UIs they see are so complex that it takes a great amount of time to be accomplished (for a web application experience). For instance, an export may take a few minutes, like 4-5 minutes. I was wondering, if there would be a way, in which I could make this task to be done asynchronously, using threads and make it to last shorter.


Is it smart to give idea to company?

I have a few interesting ideas (business ideas) that can be implemented as add-on features of existing business products (web-based products, mostly startups). Based on experience, can anyone let me know if telling them would be a good idea or not? I'm hoping to get some feedback from both sides (company insiders and outsiders). The upside: They could like it and think about bringing me on board to help build. The downside: They take the idea and implement it. Company size for one is less than 50. Another is less than 25.


Which of these looks cleaner?

I have wrote a small method in a program to do one thing my method looks like this:               public static void removeExpiredAssignments(Module module){         module.removeExpiredAssignments();     }      So the method is called like:               removeExpiredAssignments(module);      When the desired operation could be done by saying:               module.removeExpiredAssignments();       Which is easy to understand from the code point of view?


Tineye.com search algorithm?

I was wondering how does tineye carry a search. Does it store all the images and then extracts exif data? Which in turn must be stored in a database and queried against. So probably it is using some sort of keyword/pattern matching algorithm...


My manager said "We're not in the business of building controls" but I am a WPF dev

I cannot believe what just happened. I'm an expensive full stack developer, although I have focussed on WPF and Silverlight lately. Much of the time, I write Controls, ViewModels, Repositories and a bunch of asynch code. This contract I'm working today is a shambles. The code is a mess. Everything is tightly-coupled, no MVVM, and a bunch of stuff ripped from CodeProject. I taught a junior guy how work the Parts and States model, build Controls and VMs and be a great UI dev. He tells my boss that he's formalising some new feature into a control and my boss says "We're not in the business of building controls." While their sole product is a WPF client, he could not be more wrong. He just wants crap smashed out my juniors in a hurry. What would you do in this situation? How would you explain it on your CV/resumé?


Why does Java exit with success after an uncaught exception?

Any time a Perl, Python, C++ or Tcl program halts with an unhandled exception, those language runtimes take care to register a non-zero exit code for the process. Even Eclipse-based programs return 1 if they fail during startup. Programs run by the standard `java.exe`, however, happily return zero no matter how abruptly they end, unless the program calls `System.exit()` with an exit value. Even `AssertionFailedError` or `UnsatisfiedLinkError` are reported back to the calling program as successful exits. Of course not all systems have program return codes, but Unix and Windows were important enough to warrant `java.lang.Process.exitValue()` for child processes; don't they also warrant honouring conventions for parent processes? Is this a flaw in the language design or just in the implementation? Is there an argument that it's a good idea?


Is this modified BSD license compatible with GPL?

I am working on open source project, that uses the source code from FlatAssembler project, which uses following license, based on BSD 2-clause with one additional clause added at the end of the text. So, the questions are:   1. What this additional clause changes?   2. Is it legal to use this code and to license my project under GNU GPL? (The original BSD 2-clause license is compatible with GPL, but this one seems to be not.) > flat assembler version 1.71 Copyright (c) 1999-2012, Tomasz Grysztar. All > rights reserved. > > This program is free for commercial and non-commercial use as long as the > following conditions are adhered to. > > Copyright remains Tomasz Grysztar, and as such any Copyright notices in the > code are not to be removed. > > Redistribution and use in source and binary forms, with or without > modification, are permitted provided that the following conditions are met: > >   1. Redistributions of source code must retain the above copyright notice, > this list of conditions and the following disclaimer. >   2. Redistributions in binary form must reproduce the above copyright > notice, this list of conditions and the following disclaimer in the   >  documentation and/or other materials provided with the distribution. > > > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" > AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR > ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR > SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER > CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > DAMAGE. > > The licence and distribution terms for any publically available version or > derivative of this code cannot be changed. i.e. this code cannot simply be > copied and put under another distribution licence (including the GNU Public > Licence).


How can describe slow connection issues?

I have been working on a website containing 3d maps, virtual 3d tours, etc. All of the content is large like images and video. The problem is the site performs well under normal speed connections but it take more time to load if network is busy or the internet connection is slow. How can I describe this to the customer? Yes, we optimize the content where its possible.


Help to simplify/model complex decision making (if, then, else scenarios)

I find my self in a situation, where I need to program a service, that can determine if two object in a huge database are the same. For simplicity, let's say it's used cars, and I want to determine if they are the exact same, based on various attributes e.g. brand, model name, year, milage, price, color etc. The problem is, that some of the attributes are obversely more significant/critical/important than others e.g. brand/model name HAS to be the same, where as the seller might wrongly have typed in the milage a slight bit differently. Additionally some times information such as the color might even have been left out, an hence I must fall back to less "unique identifying" information such as for an example the engine size. Apart from the direct weight/importance of each attribute there is another dimension of complexity involved - the attributes' importance vary with each other. So let's say e.g. that the car I'm comparing against the rest is very old, then suddenly the importance of the milage it self increases since it's way more likely to be unique among similar cars, than compared to a younger car. This is obviously due to the fact, that the dispersion of milage on older cars are much wider than the one on younger cars. As you might imagine, modeling this as a lot of nested if-then terms easily ends up in a complete mess, and completely unreadable afterwards, and even hard to model in the first place. So my questions are: What might this kind of problem be called in programming, and how do I deal with it? What solutions/algorithms might be good solutions? References, links? Good reading on the topic?


Array or Malloc?

I'm using the following code in my application, and it's working fine. But I'm wondering if it's better to make it with malloc or to leave it as is?               function (int len)     {     char result [len] = some chars;     send result over network     }


May non-GPL-compatible scripts be linked at runtime to a GPLv3 library, by that (GPL) library itself?

First of all, pardon the title, as it's not very clear. I have an application I am writing that is GPLv3, and is in Java, which means that classfiles are generated and linked to for general operation. I am also using a scripting engine which, for performance, links any scripts it runs to my program's scripting libraries(which are class files) at runtime. Given that a script must be linked at runtime, can a GPLv3-incompatible script be run on the application? Can I legally force the script to be interpreted instead? Just to clarify I'm trying to involve the GPLv3 in restricting non- GPL-compatible licenses to scripts. The question is whether a technical linking operation functionally equivalent(except in performance) to parsing is actually linking in the legal sense. Clarification: Scripts will be transmitted to interacting instances of the application. Scripts are loaded from a textual representation in ECMAScript/JavaScript, tokenized and parsed for syntax and then linked. This is what is confusing me. Given the conveyance, is the script being compiled and linked? Or interpreted and the parser actually runtime linking itself?


Design a program and methods of doing so

I'm working on becoming a self-taught programmer. I've read a little bit through a lot of languages and I decided to start with Java and have been using it for several months now. I didn't have much of a problem since most my programs are relatively simple, or games that don't take much planing. That is until my last project I challenged myself with, making a client/server chat applications with a GUI. With only the idea in my head on how sockets worked and my newly learned syntax I started at it. Before I knew it I ended up with a jumbled mess of program that I was finding VERY difficult to work with and eventually I was just so ridiculous I couldn't get simple things to work and I had to delete everything and now I'm starting over. So I took it that I need some better practices. Now for the questions. As someone who is self-taught I'm bound to develop several bad habits, and I do virtually zero planing before writing a program aside from the idea in my head, so:   1. **What are some good ways I might start developing better programming habits?**   2. **When planning a program, are there any good methods of doing so?**   3. **Besides experience, what else is it that I might need before trying to actually take on a big real-world project as a programmer? Like one for a job.** _(How many languages should I know, what kind of problems should I be able to handle, that kind of thing. )_


Primary reasons for using REST/OData instead of a custom convention

What do you think would be the primary reasons to make APIs with REST or OData instead of just making everything custom (for example only using GET requests, even for setting variables). Reasons for the opposite also welcome. As a bit of background, it's going to be used for a request that is sent once every few minutes as a master-server updater for a game (as well as by clients for querying).


Mapping software

Okay, this might sound lame, but it is actually a difficult question (for me at-least)... Now there are many mapping software like Google Maps, Apple maps and others whose existence is outside my knowledge. But my question is how do they work? Do they use GPS to get the images or something? Even if they do, how do they give the 3d view of places? I don't think GPS can zoom to that extent... Even if they use GPS, how do they get access to the GPS satellites? I know that it is an expansive question but any help would be truly appreciated...


Using version control to manage site backups?

Last week I started making daily backups of my relatively small (~300mb) site. The backups are zipped, so it's less space, but it will quickly add up, especially as my site gets bigger. I was thinking of unzipping the latest backup, and from now on just using mercurial to add/update files from newer backups. Are there any drawbacks to this? Is there a better way to do it?


Why is 24 lines a common default terminal height?

80x24 characters seems to be a very common default for terminal windows. This answer provides a very good historical reason as to why the width is 80 characters. But why is the height commonly 24 (or 25) lines?


How to convince a client that you will not steal his idea

I came across a thread entitled How To Stop A Developer From Stealing Your Business Idea and i can't help but raise a brow. The issue talks about a developer being able to pass on the idea to another and benefit from it. As a developer, what is the best way to assure your client that you will not steal his ideas? Are there any practices, laws or anything that takes care of the interests of both sides? edit: linked to thread, and i didnt understand everything that was said


Web Frameworks caring about persistence?

I have noticed that Play! Framework encompasses persistence strategy (like JPA etc...) Why would a web framework care about persistence ?! Indeed, this would be the job of the server-sides components (like EJB etc...), wouldn't this? Otherwise, client would be too coupled with server's business logic. **UPDATE: One answer would be : it's more likely used for simple application including itself the whole business logics. However, for large applications with well-designed layers(services, domain, DAO's etc..), persistence is not recommended within web client layer since there would be several different web(or not) clients.**


Low coupling processing big quantities of data

Usually I achieve low coupling by creating classes that exchange lists, sets, and maps between them. Now I am developing a Java batch application and I can't put all the data inside a data structure because there isn't enough memory. I have to read and process one chunk of data and then going to the next one. So having low coupling is much more difficult because I have to check somewhere if there is still data to read, etc. What I am using now is: Source -> Process -> Persist The classes that process have to ask to the Source classes if there are more rows to read. What are the best practices and or useful patterns in such situations? I hope I am explaining myself, if not tell me.


Group method parameter or individual parameter?

I would like to ask on method parameters design consideration. I am usually deciding between using individual variables as parameters versus grouping them to a class or dictionary as one parameter. Is there such a rule when you should use individual parameter against using a class or a dictionary to group the parameter? Individual parameter \- Straight forward, strongly typed Dictionary parameter \- Very extensible, like HTTP request but cannot be strongly typed. Class parameter \- Extensible by adding member to the class parameter, strongly typed. I am looking for a design reference on when to use which? Note: I am not sure if this question is valid in programmers but I definitely think it would be closed in stackoverflow, If it is still not valid, please point me to the proper page.


Would you make your website's source code public?

_Back story:_ My best friend is a self-taught coder for a community art site, written in PHP. Some time ago he mentioned he wanted to make the source code of the site public, to which my response was total horror - surely it was going to be full of security holes waiting to be found, and it was going to lead to hacking and errors on a huge scale. He never ended up doing it. _Current story:_ I'm starting development of a community website built in Rails, and for ease of use I was going to use Github for version control. Then I realized it was pretty much exactly the same thing as my friend making his source code public - which made me stop and think. **Would you make your website's completely-custom source code public? Or is this a case of open source gone too far?** (note: I don't think this applies to people who run things like Wordpress. Or does it?)


how to Read in a list of values store it in a queue and change the order of the inputs?

How to Read in a list of values store it in a queue and change the order of the inputs? For example, read in `abc123efgh45678` and display `a1b2c3d4e5f6g7h8` I know I can use queue to read in the values. But how do I assign `a` to go beside `1`, eg. `a1`?               queue <char> q ;          for (int j=0; j < input.size(); j++) {       q.push (input[j]);     }


Multiple SSH keys for different organizations

I can see that GitHub allows you to have multiple mail account and associate every _organization_ you are part of with a different address. Can this be done also for SSH keys? What I would like to do is having two different keys, one to push on my private repository, another to push on an _organization_ repository.


Clojure: Adding functions to defrecord without defining a protocol

A record can implement protocols. However, each time I think of a new function that I would like the record to implement, I have to add it to an existing protocol or create a new protocol. How do I get around this? Ideally, I'd just like to associate a function to a record without having to define a protocol.


Location of Solution Components - Centralisation versus Multiple Instances versus Libraries

We're currently in the early stages of building a substantial system, aiming to do much of what several existing systems do, in a flexible, extensible, maintainable way. It will support multiple complete instances for different customers. One of the things which keeps coming up across the whole system is: **where should [component x] sit?** We could:   * **(A)** completely centralise it into a single separate web service, shared by all instances; configuration would be held centrally so that it could give each instance what it needed, and may include instance-specific plugins   * **(B)** have it as a separate service, but install it multiple times, configured individually for each main instance of the solution; the service might be used by several co-operating components within one instance   * **(C)** create the functionality as a library and incorporate it directly into the other components For each there are some clear pros and cons: **A** is resource-efficient, and easily allows e.g. monitoring of activity across the whole solution. Making a single service sufficiently configurable/flexible will create additional development challenges. Upgrades to the code might have an impact across the whole solution both in terms of down-time and testing/deployment planning, whether or not the code change is intended to improve every instance. **B** uses more resources, but localises configuration, which may be less complex. Code changes can be rolled out in a more manageable way, but more effort will be required to do the roll-out in more than one place. **C** removes the need for a separate service at all, and offers the potential for maximum flexibility if calling code doesn't have to be restricted to carrying out all functions via the web service API; upgrades to the code would require redeployment of DLLs everywhere they were used, which could be in every component of an instance rather than just once per instance as in B. I'm specifically thinking about it from a functionality PoV not, worrying about e.g. where the data is actually stored. I've ignored option D, "copy and paste code all over the place, or reimplement willy nilly". I'm wondering how it applies to a whole range of components, from specific business functions, to broader things like logging, error-handling, data- access, etc etc. I realise that the final answer will always depend heavily on each example, but are there considerations I haven't mentioned which could have a big impact? Are there examples where it's an absolute no-brainer? Is there some systematic way to help make this decision? Have I completely missed an entire option? EDIT (a little more detail just in case it makes a difference): Historically, because of a lack of forethought, we have catered to the needs of several similar but also substantially different customers by basically forking the entire codebase apart from a handful of trivial libraries. We are definitely committed to some kind of SOA approach with the rewrite, and certainly a dramatically more shared codebase, but there may still be some benefit or requirement to maintaining some separation to each "instance", by which I mean an entire collection of services providing everything needed for one customer: the customer may require their own logically or physically or even geographically separate install; one customer's instance may consist of modules A and B, another B and C and D and E. I feel instinctively that there are sort of two ways to be "SOA" here: one to have literally one of everything, and let them all work together in different ways for different customers, or alternatively to have one of each of the needed modules within a customer, but the loosely coupled nature of the services would still allow you to add one more module to an existing customer easily, or move a resource- intensive module to its own hardware for only one customer. Don't get me wrong, I appreciate all the points made, but I think I'm not quite in a mental place where merely the fact that doing something a certain way, which could definitely offer some benefit in some situations, _could_ also lead to problems if managed poorly, is wholly unacceptable. So it's best just to not even let the possibility exist even if that leads to more complexity/effort/etc. Kind of like not allowing booze in the house, because you know that if it's there you might drink it all yourself and run out into the street in your underpants, even though a quiet drink to unwind after work might be nice. I should probably stop waffling now...


What if globals make sense?

I've got a value that many objects need. For example, a financial application with different investments as objects, and most of them need the current interest rate. I was hoping to encapsulate my "financial environment" as an object, with the interest rate as a property. But, sibling objects that need that value can't get to it. So how do I share values among many objects without over-coupling my design? Obviously I'm thinking about this wrong.


logical subsystem & physical subsystem

I've done a google search on both of them, can't find much information. I was wondering what is a logical subsystem and physical subsystem (in an object-oriented system)? Also why would it be useful to keep the two separated?


Are separate business objects needed when persistent data can be stored in a usable format?

I have a system where data is stored in a persistent store and read by a server application. Some of this data is only ever seen by the server, but some of it is passed through unaltered to clients. So, there is a big temptation to persist data - whether whole rows/documents or individual fields/sub-documents - in the exact form that the client can use (eg. JSON), as this removes various layers of boilerplate, whether in the form of procedural SQL, an ORM, or any proxy structure which exists just to hold the values before having to re-encode them into a client-suitable form. This form can usually be used on the server too, though business logic may have to live outside of the object, On the other hand, this approach ends up leaking implementation details everywhere. 9 times out of 10 I'm happy just to read a JSON structure out of the DB and send it to the client, but 1 in every 10 times I have to know the details of that implicit structure (and be able to refactor access to it if the stored data ever changes). And this makes me think that maybe I should be pulling this data into separate business objects, so that business logic doesn't have to change when the data schema does. (Though you could argue this just moves the problem rather than solves it.) There is a complicating factor in that our data schema is constantly changing rapidly, to the point where we dropped our previous ORM/RDBMS system in favour of MongoDB and an implicit schema which was much easier to work with. So far I've not decided whether the rapid schema changes make me wish for separate business objects (so that server-side calculations need less refactoring, since all changes are restricted to the persistence layer) or for no separate business objects (because every change to the schema requires the business objects to change to stay in sync, even if the new sub-object or field is never used on the server except to pass verbatim to a client). So my question is whether it is sensible to store objects in the form they are usually going to be used, or if it's better to copy them into intermediate business objects to insulate both sides from each other (even when that isn't strictly necessary)? And I'd like to hear from anybody else who has had experience of a similar situation, perhaps choosing to persist XML or JSON instead of having an explicit schema which has to be assembled into a client format each time.


Naming CSS classes and IDs

_I'm quite a CSS beginner. I've read some introductory books but now I came across a sort of question that isn't answered in any of them:_ Let's say I have a basic HTML-based website with a standalone CSS file. Now I'm creating a new CSS class or ID and I want it to have a meaningful name of course because I'll probably come back to those lines a couple of times again. For creating a meaningful name there are two options:   1. I can name them `hide-upper-space` or `small-seethrough-border` \- these kinds of names are very helpful when reading the HTML file, but in CSS file there will be a mess of all these classes and IDs from all HTML documents mixed together. Moreover, when I want to remove or modify one HTML document I won't be able to clear or modify the appropriate lines in the CSS file because I won't know if they affect also some other HTML documents.   2. On the contrary, I can name them `blog-footnote` or `gallerythumbs-upper-left` and it will make my CSS file thoroughly readable, structured and easily modifiable, but it's useless information in HTML documents - when you're reading the HTML code for the footnote of your blog then _blog-footnote_ is just plain useless class name. I hope you get my point.   I'd guess that one of these options is the actual way how the CSS should be used but I can't figure out which one and why. Thank you for helping me to use the CSS the proper and effective way.


Will a computer science college degree ever hurt my employability?

Too often, I can see that there are many viable programmers without college degrees in Computer Science, Informatics, etc. Now that I've been reading more articles about underperforming education and the insignificance of college degrees (especially as a programmer), will a college degree ever hurt my employability? (Also accounting for four years from now when I do graduate) _P.S. I'm going to UC Irvine; would the school itself matter in the significance of the degree?_


is it good practice to reload a div every second

I am working on a networking site where I need to reload the notification div _every second_. I wanted to know is it good or bad to load it every second as there are some other divs _also_ loading after every 3-4 seconds. Will it cause any problem like hanging, slowing down, etc? Reloading is done by ajax:               var auto_refresh = setInterval(         function ()  {             $('#notif').load('notiffinder.php #NOOFFNOTIFFC').fadeIn();             $('#jtoloadnot').load('header.php #jtoloadnot').fadeIn();         }, 1000);


Why does the market value of PHP developers make them appear less in demand?

I decided to edit my question to hopefully make more sense: Going on salary rates alone, why is it more _desirable_ for a company to hire a Java or C# web programmer than a PHP programmer? Their salaries tend to be higher than a PHP programmer, given equal levels of seniority, and it also implies that PHP programmers are less in demand. Granted, there are more PHP developers than in most other web languages, but it's not like C# and Java programmers are rare either. To be more specific, PHP is not often marketed as a "enterprise" language and I want to know why that is. A lot of companies use it, yet most people don't usually think Fortune 100 when they talk about real-world uses of PHP, just smaller startups and web shops.


Test driven development - convince me!

I know some people are massive proponents of test driven development. I have used unit tests in the past, but only to test operations that can be tested easily or which I believe will quite possibly be correct. Complete or near complete code coverage sounds like it would take a lot of time.   1. What projects do you use test-driven development for? Do you only use it for projects above a certain size?   2. Should I be using it or not? Convince me!


Refactoring Bittersweet PHP: How can I make this less painful?

I've just been assigned a large project. The client has had multiple developers across different companies working on their (intended to be) large, MySQL driven eCommerce site. The DB schema is ...pretty good, naming is a bit rendundant but nothing real bad. The real issue is the code is in desperate need of _"OOP-ification"_. Sadly, while actually being fairly nice procedural code as far as simplicity and legibility, there are so far about 3 functions across...about 50 files. :( Thankfully these are handling database connection but there's not a single function, class or even a foreach anywhere in site that deals with page rendering. All static using _implicitly defined_ php variables and some js. Tons of reduncy and inconsistent use of code vs. html. File/directory structure is probably the worst of all **:/** The client very very much needs a custom CMS, especially for inventory control. Dynamic page generation is a must but I doubt they will want me to start over. So I ask: is there a point of attack that will make transforming this code into a more straightforward task?


What is the best way to provide open and closed source versions side-by-side safely?

My company is looking to develop and release an open source software project along with a proprietary enhanced version, similar to pre-4.0 VirtualBox. What is the best way to maintain the two code bases such that changes to the open source version can easily be incorporated into the commercial version with minimal risk of accidentally pushing proprietary code to the open source product?


If null is bad, why do modern languages implement it?

I'm sure designers of languages like Java or C# knew issues related to existence of null references (see Are null references really a bad thing?). Also implementing an option type isn't really much more complex than null references. Why did they decide to include it anyway? I'm sure lack of null references would encourage (or even force) better quality code (especially better library design) both from language creators and users. Is it simply because of conservatism - "other languages have it, we have to have it too..."?


Should I retrieve one large set of data to filter or smaller individual sets of data?

I have a company intranet that utilizes a similar set of data across many different pages and many different methods. Speaking in generalities, is it closer to "best practice" to retrieve a large dataset and filter it for each specific page or method or retrieve many smaller specific sets of data to use? I cannot really test both approaches, as I would like to pick a design approach from the beginning and use it throughout. This is for a redesign. Thanks.


What API design for storing generic data in a more specific format?

for In the project I am working on we send messages about widgets over message queues, serializing them onto the queues as XML. The XML schema contains tags for properties that are common to all types of these widget messages, such as the widget type, command name and destination. It can also contain an arbitrarily sized list of key-value pairs to allow storage of properties that are only relevant for a specific type of widget message. The `WidgetMessage` class encapsulates this data and the `WidgetMessageXmlWriter` and `WidgetMessageXmlReader` classes provide serialization to and from the XML. I have made some classes that encapsulate specific messages, for example a `FooPlaySoundMessage` for a 'Foo' widget or a `BarSetLightPatternMessage` for a 'Bar' widget. They each have a `ToWidgetMessage` instance method and a `FromWidgetMessage` static method for converting to and from the `WidgetMessage` class. Each family of messages inherits from an abstract class for that widget type, e.g. `FooMessage` and `BarMessage`, which in turn inherits from the `WidgetMessageMapping` class; this stores the common message properties and the protected methods used by subclasses for conversion. **None of these classes inherit from`WidgetMessage` since I don't want them to inherit its key-value collection property and associated methods**, hence the need for conversion rather than simple casting. I like the simplicity of my API (e.g. `FooPlaySoundMessage msg = FooPlaySoundMessage.fromWidgetMessage(widgetMessage)`), but the fact I am having to use protected methods in a base class to share functionality, and static methods to expose it, makes me wonder if there ought to be a separate class or two involved here (similar to `WidgetMessageXmlWriter` and `WidgetMessageXmlReader`). On the other hand, I thought that part of the point of OOP is to group data and methods together and so avoid "dumb data objects". So, do I have the right idea by adding conversion methods to my data objects, or should that functionality be extracted out into another class? **Update:** I think that in all the detail above of my current attempt at a design I didn't explain clearly enough the problem I am trying to solve. In summary, I have a "generic" DTO class that has some strongly typed properties and a collection of key-value pairs to store other custom data. I want to have some specialized DTO classes for each set of custom data that store all the same data as the generic DTO, except with the key-value pairs replaced by strongly-typed properties. What is the best design for converting between these two types of DTO?


Functional testing and Acceptance testing leading to redundant code

What I know is:   * A Functional test aims to test a single component (like a WebApp's Controller) from the **point of view of the developer**. => Did I achieve all the requirements to make it work well?    * An Acceptance test aims to to test a group of components together and is focused on the Business point of view. => Does my program fulfill requirements provided by the Client/Business/Customer? Today, I work on a personal project and I started following BDD/testing methods and thus created Acceptance tests and Functional tests. I notice that a lot of requirement for functional tests are exactly the same that Acceptance tests need. Suppose a webapp controller aiming to add a product to my e-commerce's basket. One of concerned functional tests would be: > _When I go to productList.html page and I call the addProductToBasket > action, I expect my controller to retrieve the right quantity and the right > product name, and expect my view to display it._ (very generic) Surely, Business would expect application to behave the same way a developer had written in some of its functional test, so in this case, an acceptance test would be: > _Given Bob enters in the product list page, when he clicks on the button > "addToBasket" near to the "Nike basket n°2" product, basket should display > quantity '1' and "Nike basket n°2"_. (specification by example) Both tests are very similar, aren't they? So my question is: Do we risk to create a lot of duplication code and redundant tests while creating functional and acceptance tests in parallel? What is a good practice? Making functional test carry about some pure technical things only, like exceptional/buggy behaviours, inconsistent variables scenarios etc... and let acceptance tests deal with the whole business scenarios side? I would even say: **Is functional testing really needed when we attach a huge importance to acceptance test?**


Is remote agile sustainable?

This is somewhat related to another question i just asked, but I'm freelancing **solo and remotely** for a contractor who is to project management, what big ball of mud is to code, so to speak. I've been thinking a lot about working on a proposition to deal with his projects in a truly agile way. As I see it, this would involve several client- friendly and web-based apps :   * basecamp for communication   * github as a repository   * pivotal tracker for user-stories and as a display of work in progress   * some tool to gather acceptance tests (will upvote suggestions !) I've done a fair bit of reading on agile, and all good resources put much emphasis on the importance of communication in the team, to the point they are _discouraging agile for non-colocated teams_. Being the only programmer this seemed less of an issue, but as I'll rarely meet the client (if at all), **I'm worried the communication may not be effective enough to enable this kind of management**. Edit : Other people on the team would include :   \- customers (business people)   \- product manager (my client's client)   \- project manager (my client)   \- ui designer


Using subclasses for DataContracts used with JSON

I have a RESTful call that can modify the state of an instance. My problem is that the JSON is different based on the type of action the user is taking, it could be a `SetProperty` action or a `SetState` action (among others). For example, a `POST /api/sample/` _would send the following JSON               {        instanceId: 12312,             actionId: 12345, // Maps to a SetState action       desiredState: 'CURATION'     }      But when calling the same URL for a _SetProperty_ , the JSON would look like               {        instanceId: 12312,             actionId: 25354, // Maps to a SetProperty action       propName: "PropA",       propValue: "user-input"      }      I use the following data contract               [DataContract]     class PostInstanceRequest {         [DataMember]         int instanceId;         [DataMember]         int actionId;         [DataMember]         string desiredState;  // Only used for SetState         [DataMember]         string propName;   // Only used for SetProperty         [DataMember]         string propValue;  // Only used for SetProperty         // Many more action specific properties here...     }      I don't really like this because it feels like I should have a base class for the common properties, and then I should define more base classes with the specific properties.   * `SetStatePostInstanceRequest`, that adds `desiredState`   * `SetPropertyPostInstanceRequest`, that adds `propName` and `propValue` However, if I do that, I don't know what class to deserialize it into. I would have to first deserialize as a `PostInstanceRequest`, check the `actionId` property, and then deserialize it to the correct subclass. A possible compromise is to use composition               [DataContract]     class SetStateAction {         [DataMember]         string desiredState;     }          [DataContract]     class SetPropAction {         [DataMember]         string propName;         [DataMember]         string propValue;     }          [DataContract]     class PostInstanceRequest {         [DataMember]         int instanceId;         [DataMember]         int actionId;         [DataMember]         SetPropAction setPropParams;         [DataMember]         SetStateAction setActionParams;         // More references to action specific classes down here     }      Which of the options is going to cause me less trouble? Or is there an even better way that I didn't think of?


Does your programming knowledge decrease if you don't practice?

I'm a novice programmer. I study languages such as C, C++, Python and Java (mainly focusing on C++). I'm what you'd call "young and inexperienced" and I admit that because I can't claim otherwise. As a student, I have many other problems besides programming. I practice programming as often as I can, and especially because my teacher gives me a lot more exercises than the rest of the class (it's a very low level), so oftentimes I spend weeks doing something else such as school projects or sports, or traveling, anything besides programming. Don't get me wrong though, I love programming. I love to build functional code, to watch as a program comes alive at the push of a button, and to learn as much as I can. The thing is, I simply don't have much time for it. Straight to the question, now: does your programming knowledge decrease as time passes and you don't practice? You may ask "how much time do you mean?". I don't mean a specific amount of time, but for reference you could take a month-two or even a year as an example. By knowledge I mean anything from syntax to language functionality.


Determine file type and then decompile to edit source

I'm new to this type of programming, but proficient in web development... looking to expand my palette a little. I have this file. In Windows 7 the file properties window claims its a 'system file', my assumption is that this is a generic description and isn't particularly useful, no file extention. This file resides on a usb drive which Windows machines can boot to to run various scripts and applications. How can I determine what type of file this is and is it possible to de-compile it to view its code or even if that's possible? Sorry for two separate questions, a point in the right direction would be very helpful! Thanks!


How to prevent piracy on software which is sold online?

When selling software online what's the most suitable/secure way to provide activation in order to get rid of pirates copies of the software? Is there any well-known software for this purpose?


Storing data for use on Android and Windows Applications

I posted this last night on StackOverflow and was advised to move it over to StackExchange, thank you for taking a moment to look at my question. I'm developing a project proposal for my final year project at University and as I aim to use programming languages I am currently not too familiar with I'm looking for some guidance - I can't include details of my project but hopefully you will understand what I'm after. I'm going to be creating an Android application (in Java) and a Windows Application (in C#) that will ideally access, query and update a remotely hosted Database or set of XML files (this would most likely be over the Internet). I've done some looking around the internet and SQLite seems like a safe-bet for cross-platform manipulation of the database; however I would like to keep the system as lightweight as possible and I'm wondering whether XML files may provide a better alternative? Anyone out there that has experience using SQLite and/or remotely hosted XML for the purposes of Android and/or C# development that could point me in the right direction? If there is an alternative solution other than those I have mentioned I would be interested to hear about them too. Thank you for taking the time to read my question. Edit: The purpose of this application is for a small scale business, the data source would not need to be updated by more than one source but may be view from multiple sources (i.e. through multiple phones and a desktop PC). The database wouldn't be updating masses of data at a time (most likely single rows of a few tables at the most).


Is inconsistent formatting a sign of a sloppy programmer?

I understand that everyone has their own style of programming and that you should be able to read other people's styles and accept it for what it is. However, would one be considered a sloppy programmer if one's style of coding was inconsistent across whatever standard they were working against? Some example of inconsistencies might be:   1. Sometimes naming private variables with _ and sometimes not   2. Sometimes having varying indentations within code blocks   3. Not aligning braces up i.e. same column if using start using new line style   4. Spacing not always consistent around operators i.e. p=>p+1, p+=1 vs other times p =>p+1 or p => p + 1 etc Is this even something that as a programmer I should be concerned with addressing? Or is it such a minor nit picking thing that at the end of the day I should just not worry about it and worry about what the end user sees and whether the code works rather than how it looks while working? Is it sloppy programming or just over obsessive nit picking? **EDIT** : After some excellent comments I realized I may have left out some information in my question. This question came about after reviewing another colleagues code check-in and noticing some of these things and then realizing that I've seen these kind of in-consistencies in previous check-ins. It then got me thinking about my code and whether I do the same things and noticed that I typically don't etc I'm not suggesting his technique is either bad or good in this question or whether his way of doing things is right or wrong. **EDIT** : To answer some queries to some more good feed back. The specific instance this review occurred in was using Visual Studio 2010 and programming in c# so I don't think the editor would cause any issues. In fact it should only help I would hope. Sorry if I left that piece of info out and it effects any current answers. I was trying to be a bit more generic in understanding if this would be considered sloppy etc. And to add an even more specific example of a code piece I saw during reading of the check-in:               foreach(var block in Blocks)     {        // .. some other code in here             foreach(var movement in movements)        {            movement.Moved.Zero();            } // the un-formatted brace        }      Such a minor thing I know, but many small things add up(???), and I did have to double glance at the code at the time to see where everything lined up I guess. Please note this code was formatted appropriately before this check-in. **EDIT** : After reading some great answers and varying thoughts, the summary I've taken from this was.   1. It's not necessarily a sign of a sloppy programmer however as programmers we have a duty (to ourselves and other programmers) to make the code as readable as possible to assist in further ongoing development. However it can hint at inadequacies which is something that is only possible to review on a case by case (person by person) basis.   2. There are many reasons why this might occur. They should be taken in context and worked through with the person/people involved if reasonable. We have a duty to try and help all programmers become better programmers!   3. In the good old days when development was done using good old notepad (or other simple text editing tool) this occurred much more frequently. However we have the assistance of modern IDE's now so although we shouldn't necessarily become OTT about this, it should still probably be addressed to some degree.   4. We as programmers vary in our standards, styles and approaches to solutions. However it seems that in general we all take **PRIDE** in our work and as a trait it is something that can stand programmers apart. Making something to the best of our abilities both internal (code) and external (end user result) goes along way to giving us that big fat pat on the back that we may not go looking for but swells our heart with pride.   5. And finally to quote CrazyEddie from his post below. _Don't sweat the small stuff_


Any Practical Alternative to the Signals + Slots model for GUI Programming?

The majority of GUI Toolkits nowadays use the Signals + Slots model. It was Qt and GTK+, if I am not wrong, who pioneered it. You know, the widgets or graphical objects (sometimes even ones that aren't displayed) send **signals** to the main-loop handler. The main-loop handler then calls the **events** , **callbacks** or **slots** assigned for that widget / graphical object. There are usually default (and in most cases `virtual`) event-handlers already provided by the toolkit for handling all pre-defined signals, therefore, unlike previous designs where the developer had to write the entire main-loop and handler for each and every message himself (think WINAPI), the developer only has to worry about the signals he needs to implement new functionality on. Now this design is being used in most modern toolkits as far as I know. There are Qt, GTK+, FLTK etc. There is Java Swing. C# even has a language feature for it ( events and delegates ), and Windows Forms has been developed on this design. In fact, over the last decade, this design for GUI programming has become a kind of an unwritten standard. Since it increases productivity and provides greater abstraction. However, my question is: **Is there any alternative design, that is parallel or practical for modern GUI programming?** i.e Is the Signals + Slots design, the only practical one in town? Is it feasible to do GUI Programming with any _other_ design? Are any modern (preferably successful and popular) GUI toolkits built on an alternative design?


Using PHP version 5.2 or 5.3 for commercial products?

I'm doing research on what version of PHP to use when creating commercial scripts that will be sold to the public. Although the available stats aren't great, PHP 5.3 shows a 18.5% adoption rate. I'd like to use Symfony to create these scripts and it requires 5.3.2 which shows an even lower adoption rate (roughly 13% of that 18.5% use less than 5.3.2). Would I be risking much by jumping straight to PHP 5.3.2+ or should I ignore the stats and plough ahead?


What's the term describing this system for generating user interfaces?

So, there's this idea, which you already know: Define the layout of your UI by creating a tree of panels. The leaf nodes on the tree are what we used to call 'controls' way back in the day-- the things that the user interacts with, radio buttons and listboxes and such. The internal nodes are mostly concerned with layout; this kind of panel stacks its child panels vertically, that kind puts its children into a grid, etc. It's COMMON. Most of the UI-generating systems I've seen in the past twenty years are implementations of this, and the ones that aren't borrow from it. What's the word for this idea? EDIT: I'm looking for a word, or a phrase, for the _pattern_ I'm describing. It's a big, high-level pattern, and it's become nearly universal. AWT, HTML forms with the controls in table cells, Swing, XAML, Android, and ASP.NET all use it or borrow from it. There's an idea here, on the same level as concepts like "windowing system" or "mesh network." What do we call it? I suspect that the real answer is, "there's no consensus on a name for it yet." Which would, itself, be really interesting.


What are the absolute, minimum requirement for containing SE Asian charsets for an embedded system project?

I work for a company that has begun integrating embedded computer systems into our products that we manufacture. We have a pretty wide range of products and they are distributed across the globe. Additionally, we've designed a few integrated boards that can serve multiple purposes depending on the firmware that has been flashed to the system. This way we don't have to redesign our computer hardware for our various products-- all we have to do is re-write the firmware layer to meet the specific product's needs. Because of these hardware limitations, changing our hardware takes an act of congress but writing new software for a hardware is much simpler (relatively speaking.) One of our products has a new requirement that we haven't had to previously implement, which is the need for user-inputted text. Currently, we've been able to store international text in resources and only the necessary fonts characters are compiled to bit-mapped images. This means that we've been able to store highly-ideographic languages like Chinese and Japanese text in a minimal amount of space because we only use a very small percentage of the entire language set. Since this new product will require that our users be able to input text, we will have to implement an extensive character set. As primarily a PC developer, I'm quite familiar with ASCII, Unicode, UTF-8, etc., however, implementing a full character set of any of these languages isn't feasible because we have a limited amount of FRAM on the board to store the font data. My management is hoping that there is a minimal character set that can be used for highly ideographic languages. I believe there is a phonetic alphabet for Japanese (the Hiragana?) Are there similar phonetic alphabets for the Chinese, Korean, Vietnamese, etc. languages as well and, if so, could speakers of these languages communicate with such a narrow character set? I'm pretty sure the answer to that question is "absolutely, no" but it's a question worth asking. Management has set a "soft" requirement that we can only have a limited character set of about 8,000 characters covering all major languages in common use. If this is not possible, we need to look for some form of alternative method for meeting our needs based off of our limited hardware resources. I'm sure this problem has had to have been solved before. Does anyone have experience working within such constraints while needing an extensive font and character encoding system? If so, what nuggets of wisdom or tips can you offer? Thanks in advance, devs! We are in a feasibility stage of development so we are mostly looking to get a list of all of our realistic options.


How to share problem solving knowledge in a multiteam group?

I've been working in multiteam groups for as long as I've been a web developer, and in my experience, a team can be a lonely soldier or several people; generally a company will have multiple teams working on different projects and once the project is out in the wild, any team can perform maintenance on it. This is a simple example since I'm not talking only about project related knowledge, but "craft related" knowledge, but it should give you an idea of how I'm used to working: Since we work on modularised teams, sometimes I feel like the teams are too tightly focused in their projects. I've seen cases where after an hour of discussion, the question was asked aloud and someone on a totally unrelated project suggested a much simpler solution. The problem is difficult to solve because people tend not to be available all the time, and sometimes the person with the knowledge can't afford the time to go through a problem with the asker, but could do it themselves easily. I've thought about software based solutions, something along the lines of SE, but I'd like to know other programmers opinions on the subject. **EDIT** I don't know if this is a problem that a wiki can solve, because I feel that wikis don't encourage the user to actually ask questions, but rather to write articles, and sometimes we don't know the knowledge we need before needing it.


What do you need to succeed with Agile?

Agile adoption can fail in some organizations, I even worked for a company where waterfall was the only (the true) way but only because they tried Agile on a project and failed. When I asked the people who still remembered that (I was a junior) I was shut down hard, like I was reminding them a bad nightmare that really happened. I don't know why the project failed. There are resources found on the web why Agile fails is some companies but the reason are mostly economic. So I thought I ask here fore some feedback. What are the reasons Agile adoption fails in some organizations? Or, another way of putting it.. What do you need to succeed with Agile?


Is it possible to learn maths via programming, or you should learn maths for programming?

I am not the best in maths, not very horrid either, but lower than the average, I've always been thinking to improve my maths, but schools and books didn't do the job because I get bored too fast. The only thing I don't get bored with is coding and gaming, so I thought what if coding a program that solves mathematical problems will help me understand maths better, most of these problems are limits (calculus), functions, Differential calculus, and some other subjects (I already said am not that good) similar to the previous noted. My question is: Am I able to achieve a better knowledge in maths if I do some specific program coding, and if possible, is physics possible that way too? Or am I wrong and Maths should be learned before programming to help improve my coding? P.S : C++ is the preferred language.


Unit testing markup building logic

I'm currently writing a library of helper functions to produce some repetitive markup. I have a reference to the markup the functions should produce, but I'm curious about how I should go about unit testing this? There are a lot of unit tests needed to get full coverage of the number of different variations of output from each function. Currently, I have a T4 template for each function which builds unit tests for every combination of inputs to that function. Each unit test does a single assert against a string containing the reference markup. However, writing out these individual bits of markup by hand would take a long time so I wrote another small helper function which basically replicates the same logic I'm testing, but in a less flexible manner, to produce the expected string. **It occurs to me that this may not be the best idea? Or is this an OK approach to this kind of problem? What are the best practices surrounding this?** * * * Example unit test               [TestMethod]     public void Function_P1_P2_P3()     {         string markup = HelperLib.MakeMarkup(P1, P2, P3);         Assert.AreEqual(this.MakeExpectedString(P1, P2, P3), markup);     }


What do we mean by "design" in software engineering?

I have been reading about different software methodologies. Every method has a design phase to some extent, more or less. I am not clear on what we mean by designing. Does this mean writing your thought process on how you will code the feature? Or it is a way of saying what you have coded or will code. The point where I am most confused is the real world, which is different than putting your thoughts in documents and saying it will work. Since coding details can change, I don't know what's the point of having a design before coding.


How useful are infix operators in a programming language? Are they worth the extra complexity they provide? Can you provide any examples where infix operators are better suited to the problem that can't be handled by just overloading the normal operators?


Is it possible to import vb.net form to blend?

I have created a windows form using visual studio design, that is simply drag n drop component into the form from Toolbox. Is it possible to import it into Blend and change its appearence using Blend? I opened the project from Blend but ony the code appears not the form itself. Thanks in advance!


How do you handle multiple developer configuration in a project?

I've been thinking lately about how I handle config changes between multiple developers on a project. Specifically here about a Laravel project in PHP, but I guess this applies largely to all frameworks/languages. In general would you say it's a best practice to not commit your configuration? If so what's your practice for doing this with version control such as git? Or do you set up each configuration as a different environment config? E.g. In Laravel there are environment configs, so each developer has a directory of just their own different settings, and this is what I'm _currently_ using. Then in the code you can set how Laravel will detect which environment it's on. This works, I'm just wondering what other developers working on projects with other developers do.


Practical use of generic inheritance and interactions with non-generics?

I've been trying to learn more about generics, and I finally felt that I ran into a situation that it would be more useful to use it instead of only regular classes. Would the following be a practical use of generics? A spaceship has hardpoints that can equip only certain types of equipment. The equip function has code to determine if the hardpoint can equip an equipment item based on what the generic parameter T is assigned to.               class Equipment {     ...     }          class Thruster : Equipment {     ...     }          class Spaceship {         void Equip<T>(Hardpoint<T> hardpoint, Equipment equipment) {             hardpoint.Equip(equipment);         }     }          class Hardpoint<T> where T : Equipment {         void Equip(Equipment equipment) {             ...(check if equipment inherits from or is of type T)         }              ... (some other code common to all hardpoints)     }          class ThrusterHardpoint : Hardpoint<Thruster> {         .... (some code specific to thruster hardpoints)     }


Dealing with estimates as a junior programmer

I have been working for a couple of months now in a company that estimates (for the general population, not juniors specifically) tasks and then we are given the task, solve it, it goes through two tests and at the end the estimate should be somewhat met. I am beyond stressed because some of the estimates are simply impossible for me to meet. I still don't know the entire system(because it is quite substantial) so sometimes half the time is spent finding out what i need to do and where and by the time I finish sometimes the estimate is over and there is still testing to be done (and correcting mistakes if they were any). The second time I have to deal with a similar functionality it all works much faster, but so far I feel like I am just bad at programming. Is there anything you did when you were just beginning that helped you get over this stage? I get so stressed when I see how little time there is to code that sometimes I can't even focus properly at what I'm doing which makes it even worse.


How to make the transition to functional programming?

Lately, I have been very intrigued with F# which I have been working a bit with. Coming mostly from Java and C#, I like how concise and easily understandable it is. However, I believe that my background with these imperative languages disturb my way of thinking when programming in F#. I found a comparison of the imperative and functional approach, and I surely do recognize the "imperative way" of programming, but I also find it difficult to define problems to fit well with the functional approach. So my question is: How do I best make the transition from object-oriented programming to functional programming? Can you provide some tips or perhaps provide some literature that can help one to think "in functions" in general?


Compiling multiple languages and Javascript

I have read numerous times that programming languages when making games or large software often use multiple languages / scripts together. I'm wondering how that works. How do they compile it? How does it work together? Also, how does this work with web design also, i.e. How does one combine their HTML/CSS with their Javascript code and make it run? I know these are really basic low level questions, but I cannot find information on this on google. I'm probably just not searching well enough.


What is language-agnosticism and why is it called that way?

When is something language agnostic? Why is it called that way?


Should a unit/integration test that may result in an infinite loop have a clear assertion?

Unit: A multithreaded unit reads data of a queue and processes it, sending it off to another queue. When the last item is processed (null value found) the process stops. Test: Place a set of known data in the queue and run. Check that data placed on the output queue is correct. If the unit is incorrectly programmed, it may continue trying to read and process nulls of the queue. This may or may not result in an exception (using Java as the example language). So this test could conceivably cause an infinite loop. Should the test keep track of the number of items read off the queue and throw an error if more than the specified number of elements is read? or should the test continue to run, knowing that the runner(human) will see that it is not ending?


Given some random letters , For example "a,e,o,g,z,k,l,j,w,n" and a dictionary.Try to find a word in the dictionary that has most letters given I was going through some old interview questions and found this question, I am new to algorithms and I am thinking whether this can be related to dynamic programming(Longest common subsequence) this is the solution that I can think of "Let us assume that the dictionary is in a trie Start by finding the permutations of the given letters, here we could be using recursion, we can prune the recursion tree, by checking the letters in the dictionary. and we maintain a variable which holds the largest string formed till now." I tried searching online but could not find any example that match this could you provide some pointers.


How to algorithmically add notes to an existing midi file relative to positions of existing notes in python

I have a midi file that I'd like to algorithmically add notes to relative to other notes that already exist in the midi file using python, or if it's easier using a different language I'm open to that as well. So basically, I have a midi file with a bunch of notes, and let's say I'd like to add 5 or 6 new notes surrounding each of the existing notes with timing differences that are randomly generated (for example time differences with a random amount of milliseconds difference between -10 and 10). So with each note already existing in the midi file I'd add 5 or 6 new ones surrounding it to a new midi file, offset by a randomly determined amount of milliseconds. Also, if possible, I'd like to randomly vary the velocities of each new note in the same manner relative to the note in the original midi file. The only part I'm not sure how to do is read and write into a midi file based on its note onset contents?


Test driven development when implementing a flexible length list

According to the commonly used TDD strategy, to implement something, you write a test that fail the code first, write the simplest code, refactor, and then repeat. I am trying to imagine this scenario with implementing a flexible length list (e.g. `List<T>` in .net. Let's say I first test by inserting one item. Probably the simplest way to achieve this is by backing the list with an array with length 1 (which will pass the test). Nothing to refactor here, so I'll go ahead and write another test that insert 2 items. I'll simply change the array length to 2, and the test pass again. Then I write test with 3 items, expand the array, and repeat again. I will end up forever doing this until I'm tired. Is this an exception to the fail-test-first strategy? Or am I missing something in the above strategy? PS: The actual implementation backs the list with an array which grows twice as large every time the number of elements exceed the array length.


Should I read "Head First Design Patterns" as my first design pattern book?

I'm planning to read a book to gain some good knowledge of design patterns, why we use them, how to apply them and how to choose the best design for my software. So I have two books on my desk right now: "Head First Design Patterns" and "Design Patterns: Elements of Reusable Object-Oriented Software". Which one do you think I should read as my first book about design patterns?


Techniques and methods to improve and speedup development

I just got a new project. It’s a WinForm app. And it’s interesting because I will have the possibility to learn how fish farms work and are managed. I will have to develop touch interfaces, and use datasnap to communicate and sync data between farm and office. The development will be done in DELPHI win32, still not sure about the database, but maybe SQLlite. So now comes the difficult part of the project, building it. I am just finishing one. It took me a lot of time to do it and I am a bit “burned out”. I will have time to relax, not much, but a few days. What I am looking is some tips and tricks and possibly tools to be able to speed up the development. It must be up and running in 2 months. So what tricks do you use to speed up things?


Potentially shippable product requires automating tests

To always have a potentially shippable product at the end of each 2-week Sprint, we need to rerun a lot of regression tests at the end of each Sprint. This is very repetitive and time consuming, so eventually it will probably be cost-effective to automate these tests. However if we don't require a potentially shippable product, but plan for a few stabilization/hardening Sprints, we don't need to rerun all our manual tests each Sprint. In such case automating our tests will not be cost- effective. So which approach do you prefer, to automate tests, to forgo the shippability advantage, or do you think that this trade-off doesn't actually exist?


Live share prices for a side project

Me and some of my friends would want to start a side project which we will work at our spare time. Here is our criteria 1) A challenging project which will teach us skills which has business value in the future. 2) A potential to make money from the project itself. Quite obvious targets. We are looking into the possibility to create a live price feed. We understand we cannot match the ones in the market now. But we are looking into the possibility to provide a feed which could at least provide a "live" feed, even though it cannot match the real time performance provided by the insane hardware and software resources the "biggies" could provide. If we could host the feed in a website which can show prices even 5 minutes late, that could do. The current skills pool is C++ and C#. We have WPF, asp.net, silverlight skills for UI (UI doesn't matter much anyway) The questions 1)How is it possible to get the raw price feeds for cheap(or free)? 2)Is it possible to do this idea at least as proof of concept(which means it might not have any commercial value) in a year by 3 developers working 20 hours a week? 3)Is there any information available in the internet to start with? 4)Is there any open source projects in this area?


Could one sample be enough for a perceptron training?

I need to compare a picture and decide whether or not it is similar to another one. In this case, I would like to use a simple perceptron that compares pixelmaps of both pictures. But I have only very basic understanding of neural networks and I am not sure whether this approach will work if there is only one source picture (to train it with). Anything I could do in this case?


Fun socializing programming ideas

Recently a friend of mine went the Hackfest sponsored by Quick Left. Which sounded like a lot of fun, and I kind of wish I could have participated in it myself. So, now I'm looking for ideas that like the Hackfest that could help developers on my team innovate, and think wildly about how do stuff with the Web, etc. Anyone have some ideas?


Are naming convention guidelines worth caring about?

I name my variables using the .Net conventions:   * camelCase for variables and fields (I tend to use _camelCase for private fields in a class)   * PascalCase for methods, properties and classes The only place I deviate is on constants and Enums where I actually prefer the Java SCREAMING_CAPS style. My company's codebase is littered with the pseudo-Hungarian notation style from VB6 and VBScript, if not full-blown Hungarian i.e.   * s or str for Strings   * i or int for Ints   * d for decimal (or sometimes double)   * o or obj for any kind of object I cringe whenever I see that code style used in someone else's code (even in greenfield code, not just the legacy cruft), and I refuse to use that style myself. I've brought up standardizing on the .Net naming conventions in the past and it's just ignored - the people who write in Hungarian notation continue to do so, those of us who don't like me continue to use our own style; I'm a little afraid that if we **do** standardize (which I keep pushing for, but nobody else seems to care), it'll be on Hungarian notation and not the recommended way and then I'll be forced to write code like that. Am I making a mountain out of a molehill in regards to this? Should I not care if the code is littered with redundant identifiers and not descriptive names, and continue to use my own way and push for that to become the standard?


How to solve a general authentication problem for multiple applications?

At my current job (we're in a MS environment), we have multiple deployed web applications, both inter/intra net. The internal apps generally use an Active Diretory sign in, the forward facing sites each have their own membership implementation. Some use a custom provider we wrote, some use Asp.Net membership. Yes, we have created a problem for ourselves. The question is how to fix it. What would be the best (or at least good) solution for a authentication/authorization service that would allow us to consolidate sign in to one place? Should we implement an oAuth/xAuth provider? Something else? Some questions I was thinking of:   1. Should roles be left to each application to implement? In general, we could think of each resource as having CRUD permissions and perhaps decorate controller actions with required permissions.   2. We have a few really, really legacy web apps (.Net 1.1) that mostly just sit there and run. Where should we draw the cutoff for what we apply this new service to? If there's something else I should be considering, please let me know.


How to refuse to give an access to passwords to a customer without being unprofessional or rude?

Let's say you're creating a website for a customer. This website has its own registration (either combined with OpenID or not). The customer asks you to be able to see the passwords the users are choosing, given that the users will probably be using the same password on every website. In general, I say:   * either that it is impossible to retrieve the passwords, since they are not stored in plain text, but hashed,   * or that I have no right to do that or that administrators must not be able to see the passwords of users, without giving any additional details. The first one is false: even if the passwords are hashed, it is still possible to catch and store them on each logon (for example doing a strange sort of audit which will remember not only which user succeeded or failed to logon, but also with which password). The second one is rude. How to refuse this request, without being either unprofessional or rude?


Change of session/context in rails application

I'm currently developing an app in Ruby on Rails with a social network side, and have several different models including users, groups and pages. I would like to allow users to be group/page admins, which seems relatively straight forward, however I would also like users to be able to message groups/pages directly, rather than having to state the group/page admin. This is what is done in Facebook. However, I am unsure how this would be done. In order to 'take over' a group/page, would I need to destroy the session and start a new one as the group/page in order to read messages and edit the profile, etc? Another option is just give each admin an extra mailbox and admin rights to edit groups/pages, but this seems like it could get over complicated if a user admins several groups/pages.


Differentiating between user script input formats

I have a .NET project at work that provides a couple of (Iron)Python scripts to the customers, to allow them to customize the output of the program. The application generates code for certain machines, and supports a couple of different formats. Until recently, we only provided a script for one format. We're expanding upon that to include support for the others. If the user is using a script, they select their input script before generating the output code. A script designed for `Format1` output is going to cause errors if they're trying to generate `Format2` output. I need to deal with this. One option would just be to let the customers use common sense, and if they load the wrong script it will just fail, or worse, produce inaccurate data. I'm inclined to provide a little more protection than that. At the moment I'm considering putting a shebang-style comment line at the top of the script, ala:               # OUTPUT - Format1      If the user tries to run a `Format2` _process_ with a `Format1` _script_ , it will warn them. Alternatively I could create different file extensions for the input scripts that vary by type. The file-type comment approach helps prevent the script from actually loading improperly, at the cost of failing to warn the user until they've already selected it, via a dialog box. Using different file extensions would allow me to cut down on visual clutter when providing a File Dialog, but doesn't actually stop them from loading the wrong script. So I'm really not sure if the right approach is to just leave it alone, or provide some safeguards.


How much warnings in C to enable?

This is a tiny project of about 2000LOC. It is being compiled with `-Wall`. Now, I tried adding `-Wextra`. Two things happened:   * Some minor but valid warnings popped up, e.g. Comparing signed with unsigned   * Some minor but false warnings popped up, e.g. Unused function parameter. Those functions implement agreed-upon prototypes. But the extra parameters are really not needed for now. However the unfixable warnings pollute the build log and could hide a much more dangerous warning. _Should the -Wextra be retained or removed? How can a compromise be made for the most robust code development in the future?_


What's the most important feature of quality software?

This question is along the same lines as this one, but instead of talking about quality of code, I'm talking about the final product from the users' perspective. If you had limited time / budget, and could only guarantee one attribute of the software (other than the basic requirements) that take it from decent software to good quality software, what would you consider most important? Is it having as few bugs as possible? An intuitive interface? Helpful error messages? Good technical support and documentation? If we don't want our software looking like cheap crap to our users, what should we always remember to include?


What route to take to become a systems developer?

In the past I have done a lot of Java and Python coding. Mostly, I worked on web apps and some simple console or gui apps. I also have a formal education in computer science. What route should I take to become a systems developer? I always did like C++, but never had a chance to use it for anything. Would mastering C++ be one of the steps? If so what resources can you suggest? Also, I would like to know how much different is the work between plain old development and systems development. There seem to be a lot of overlapping between the two.


What is Oracle's commitment to Java?

We are investing heavily in Java, but after recent experiences and reading Joonas' response on that question: > Had you used those flags in Java 6, you could have experienced not only > crashes, but incorrect execution of loops, that is, miscalculations, because > of a minor upgrade from 6u19 to 6u20 (approximately). ... and the related blog post about the notable Java 7 issues has caused us to worry about Java's quality moving forward. Are these issues being addressed by Oracle? What assurances has Oracle provided to ensure Java is well-supported in the future?


Multiuser's impact on Access Database

Can someone explain to me how are effected the performances of an Access 2003 DB when it's used by a lot (30) of users on the same LAN? I'm working on a vb6 project with this access 2003 DB wich performs ok on my local PC, but it's terrible when used across 20-30 users. It's there something I can do to improve performance? How can I understand what's the cause of this degradation in performance?


As a practitioner, why should I care about Haskell? What is a monad and why do I need it?

I just do not get what problem they solve.


Thread class design?

I have a method like this in my UI code:               void MyDialog::OnCommandSaveData()     {         std::list<MyClass*> objects;         service_->GetAll(objects);         dataService_->SaveObjects(objects);         AddMessage("Saved data.\n");     }      Because this method can take some time, I want to kick off a thread to do this. I'm using C++ and I plan on using Boost.Thread. So my question is how to best do this. My understanding is that I need to create a static function, static method, or functor which will contain the above code. Where should this live, in the dialog class? That just seems wrong, but then again maybe not. And then I will need a mutex and lock around at least the SaveObjects method. Where should the mutex live and where do I put the lock? Most examples of threading, as with examples of so many things, don't show the threading in the context of a real application. They show a main method with a global function and that's it. So if you can point me to example of a class that manages threading for an operation that would be great. I buy the logic in the accepted answer to this question: Is It "Wrong"/Bad Design To Put A Thread/Background Worker In A Class? However, the answer only tells you why to do it, not how. **UPDATE** I've refactored my code using MVP (Model View Presenter)/Humble Dialog Box pattern:               void MyDialog::OnCommandSaveData()     {         presenter_->SaveData();     }      So now I will need to look at adding multi-threading in the context of MVP. **UPDATE 2** I found this article which talks about creating mulithreaded winforms using MVP. It's in C# so I'll have to translate it into C++ but it looks good: http://aresterline.wordpress.com/2007/04/17/multi-threaded-winforms- application-mvp/ Basically it involves 1) creating a `ThreadSafeView` which is a wrapper or proxy around your view that allows your view to be updated from a worker thread. And 2) creating a `ThreadedPresenter` which allows presenter methods to spawned in a new thread. I really like how this isolates the threading code from the view and the presenter code.


how do i tell my boss that i don't know how to do what he wants me to

my boss recently gave me details of a new program he wants me to write. After I started thinking about he told and doing some research, i feel like the project he has given is outside of my abilities.how do I let my boss know?