title: How to design the relation between a Game and a Player in a game?

text: I am currently attempting to make a Trading Card Game and I have got a whole array of features working already, yet I am stuck now at the portion where one player can attacker another player (more strictly: the monster cards of another player on the field). The game is designed primarely to be played with two players in mind, though having it open for future extensions is never a bad idea. This is the design I have so far, shown as a minimalistic example in pseudo- code:               class Game         private final Player self         private final Player opponent          class Player         private final String name         ...      The game loops over all players and lets them do their turn, which may involve attacking another player. That method has the following structure:               class AttackMonsterAction         private final int monsterIndex         private final int targetMonsterIndex         private final Player targetPlayer              public void performAction(final Player player)      If it is of any relevance, I am coding this in Java. My concrete question is the following: How do I create my class design such that `AttackMonsterAction` called from a certain `Player` object, can reference "the other player"?


title: Why did Alan Kay say, "The Internet was so well done, but the web was by amateurs"?

text: OK, so I paraphrased. The full quote: > The Internet was done so well that most people think of it as a natural > resource like the Pacific Ocean, rather than something that was man-made. > When was the last time a technology with a scale like that was so error- > free? The Web, in comparison, is a joke. The Web was done by amateurs. -- > Alan Kay. I am trying to understand the history of the Internet and the web, and this statement is hard to understand. I have read elsewhere that the Internet is now used for very different things than it was designed for, and so perhaps that factors in. What makes the Internet so well done, and what makes the web so amateurish? _(Of course,Alan Kay is fallible, and no one here is Alan Kay, so we can't know precisely why he said that, but what are some possible explanations?)_ *See also _the original interview_ *.


title: Applying DDD to a simple app with a configuration twist

text: I’m using the light-weight PHP Fat-Free Framework as a base to form a simple MVC based app with DDD philosophy for the Model layer. I’m aware that DDD is most suitable or enterprise solutions and that applying DDD to simple, mostly data-driven apps is kind of an overkill, but there are some concepts in DDD that I find appealing (like the Repository pattern, business logic in Entities, etc.) which I’d like to apply to my app. Fat-Free Faramework has a Base class that represents the application (a Singleton) and the instance of Base holds a lot of useful tool methods and a registry of global framework variables (the hive) which is used, among other things, for configuration data. As I’m writing my app, I find myself using a lot of Base class tools inside classes in the Model layer, and I’m a bit confused by how to reference the Base instance in those classes. Do I simply call Base:instance() inside model classes or do I inject it through the constructor as a dependency? Dependency injection seems like the proper way to do it, but since most of the app will depend on it, the whole reference passing through the constructor seems unnecessary. Also, how to pass for an example database config data to data persistance classes which is stored in the hive? Should it be passed by the Controllers when instantiating Repositories or called directly from the Repository (or Data Mapper)? I’m looking for a way which won’t fire back on me, so I’m looking for any insight or advice on this. The second part of my problem is that I’m trying to write my app so that each Entity and business logic related to it is configurable from the Entity class. This is an idea inspired by Sails.js I’m still testing out, but for an example, I have a method getProperties() which returns an array of user- defined configuration data for each Entity property, e.g.:               'title' => array(         'type' => 'text',         'minLength' => 30,         ...     )      or for associations:               'children' => array(         'entity' => 'ChildClass',         'relation' => 'oneToMany'     )      It might look a bit controversial, but I’ve tested business logic functionality and so far it works OK for me, and client code communicates with entities via usual get/set/other methods. The idea behind such configuration is to be able to automatically generate scaffolding/administration interface for each Entity, and configure Data Mappers and Repositories based on the related Entity’s getProperties() method. What’s bugging me now is that if I want to have _one_ place where this configuration data exists, I’d have to place some non-business-domain logic into the Entity, such as an exceptional database table name, whether a field requires a rich-text editor or not, whether a checkbox is checked by default, a certain field used as an Entity’s print identity in the admin web interface, etc. I realise that the problem I have is a tradeoff between a clean model and the single-place configuration idea and that I’ll probably have to pollute the Entities by storing such non-business-domain data into the Entites, but I thought perhaps someone here might have an idea about how to approach this in a different, or better way? Thanks for reading.


title: Why does Java use so many middlemen?

text: For example to read data from a website we do:               HttpResponse httpResponse = httpClient.execute(httpPost);             HttpEntity httpEntity = httpResponse.getEntity();             is = httpEntity.getContent();      The method that executes the HTTP request, returns a response, then we turn the response into an entity, then we turn the entity into a input stream, then you got to use two more objects, a buffer reader and a string builder,to turn that is into a string. It just seems like a lot of repetitive code. Why can't HttpResponse have a method that returns an InputStream, or better yet a String? P.S. I'm not necessarily saying that Java is wrong, I want to find out what the reason behind it is, if any.


title: What are the solutions to the Distributed Queue problem?

text: I am trying to learn more about the various ways that the problem of a Distributed Queue may be solved. So I would like know what products, services, implementations and research papers that are already out there. An implementation will face many challenges and will be forced to make tradeoffs:   * Does it have strong or loose ordering?   * Does it have idempotent put?   * Can we have more queues than what can fit on a single machine?   * Can we have more data in a queue than what can fit on a single machine?   * How many machines can crash before we potentially lose data?   * Can it tolerate net-splits?   * Can it automatically reconcile data when a net-split is fixed?   * Can it guarantee delivery when clients can crash?   * Can it guarantee that the same message is not delivered more than once?   * Can a node crash at any given point, come back up, and not send out junk?   * Can you add nodes to, or remove nodes from, a running cluster without down time?   * Can you upgrade nodes in a running cluster without down time?   * Can it run without problems on heterogeneous servers?   * Can you “stick” queues to a group of servers? (example: “these queues are only allowed in the european datacenter”)   * Can it make sure to put data replicas in at least two datacenters, if so available? I have no illusion that any implementation will be able to say “yes” to all of that. I am merely interested in hearing about the various implementations; how they work, what tradeoffs they have made and perhaps why they decided on their particular set of tradeoffs. Also if there are any challenges that I may have missed in the above list.


title: Making Separate Assemblies For Different Types Of Tests For The Same Component?

text: I was told by a few members here that splitting up my unit tests into different assemblies for different components is the best way to structure unit tests. Now, I have a few questions about that idea.   1. What are the advantages of this? Organization, and isolation of errors?   2. Let's say I have a component named "calculator", and I create an assembly for the unit tests on "calculator". Would I create a separate assembly for the integration tests I want to run on "calculator"? Or is the definition of an integration test a test across multiple components, like "calculator" and whatever else, which would require a separate assembly to test both of them together? In that case, would I have one assembly to do all of the integration testing for every component combination?


title: What's the proper way to exit program in C?

text: There are many ways how to exit program in C. Some of them are returning zero or error code, using exit function with EXIT_SUCCESS, EXIT_FAILURE, exit(0), exit(1) or some other error code, abort and probably few more I can't think of now. My question is which option is the best and why. I'm asking here because every time I asked more experienced programmers this question, it ended up as a holy war.


title: MSFT released "ASP.NET Developer Guidance" PDF... What's missing in your opinion?

text: Microsoft created this ASP.NET documentation map that aggregates a ton of great links into a single PDF. http://blogs.msdn.com/b/jmeier/archive/2010/10/26/asp-net-developer-guidance- map.aspx?CommentPosted=true I'm interested in hearing what others have to say about this doc, and if they think other resources should be added. Perhaps MSFT will read this thread and incorporate your tips in this all-encompassing ASP.NET learning guide as well.


title: Does cherry-pick just pull changes into the current working tree as uncommitted changes?

text: My team uses Mercurial for version control. Our development / version control routine is:   1. all been committing to the same branch   2. pulling for changes and rebasing our commits locally before pushing back to the hosted repository This keeps everyone in sync. And the latest code (even unfinished code) is than grabbed from the tip of this branch and put into our test environment. I've been tasked with creating a management process where we can more cleanly extract "completed features" into the test environment. I've advocated that we begin to `branch->pull-request->merge->close branch` process, but I've been told that `branching` is not an option, and that the project director would prefer too be able to _manually select commits representing completed features/bug fixes_ and only include those commits in a deployment to testing. I am not sure what terminology besides `cherry-pick` in GIT / HG that would represent this process, and if it would even be advisable as the commits would no-longer have a proper revision history as it's my understanding that `cherry-pick` just pulls changes into the current working tree as uncommitted changes _correct_?


title: As a programmer, should I know low and high-level programming languages?

text: I been contacted to do some work remote controlling LEDs displays over TCP/IP, but my experience and preparation is mostly about high-level programming language. I said that to the person who contact me about the work and he told me that: > "if you call yourself a programmer you should know all these things" Should a programmer really know the details of low-level programming? Or can I treat it as a black box concept, as theoretical knowledge but not necessarily doing it or implementing low level language solutions, having in mind that low-level programming is not my expertise?


title: How to design a scriptable communication emulator?

text: Requirement: We need a tool that simulates a hardware device that communicates via RS232 or TCP/IP to allow us to test our main application which will communicate with the device. Current flow:   * User loads script    * Parse script into commands    * User runs script    * Execute commands Script / commands (simplified for discussion):   * Connect RS232 => RS232ConnectCommand   * Connect TCP/IP => TcpIpConnectCommand   * Send data => SendCommand   * Receive data => ReceiveCommand   * Disconnect => DisconnectCommand All commands implement the ICommand interface. The command runner simply executes a sequence of ICommand implementations sequentially thus ICommand must have an Execute exposure, pseudo code:   * void Execute(ICommunicator context) The Execute method takes a context argument which allows the command implementations to execute what they need to do. For instance SendCommand will call context.Send, etc. **The problem** RS232ConnectCommand and TcpIpConnectCommand needs to instantiate the context to be used by subsequent commands. How do you handle this elegantly? **Solution 1:** Change ICommand Execute method to:   * ICommunicator Execute(ICommunicator context) While it will work it seems like a code smell. All commands now need to return the context which for all commands except the connection ones will be the same context that is passed in. **Solution 2:** Create an ICommunicatorWrapper (ICommunicationBroker?) which follows the decorator pattern and decorates ICommunicator. It introduces a new exposure:   * void SetCommunicator(ICommunicator communicator) And ICommand is changed to use the wrapper:   * void Execute(ICommunicationWrapper context) Seems like a cleaner solution. **Question** Is this a good design? Am I on the right track?


title: Where to find Hg/Git technical support?

text: I would like to out who provides technical support (commercial) for two major DVCS's of today: Git and Mercurial. This is for a place where they've been using Subversion for some time and now they're renewing their software licences. Although they will be keeping Subversion as well, they would like to justify beginning of DVCS as an alternative system. Most people root for Mercurial since it seems simpler; mostly engineers and physicians there who are not that interested in checking Git repos for corruption and the finer workings of Git, but I believe any one of the two could "pass". The system has to have a price (can be zero; no problem there) and some sort of official technical support. It is a _pro forma_ matter, but it has to be specified. _**So, I'm asking you: do you know where could one go for commercial Git or Mercurial technical support?_** Technical forums and the like are out of the question. It has to work on the principle:   * _I have a problem._   * _I post a question with the details._   * _I get an answer in specified time. It can be "we cannot do that." but it has to be an official answer and given in agreed time._ I'm sure by now most of you understand what I'm asking, but if not — post a comment or similar. Also, if you think of any reasons which could decide justification of introducing Git/Hg from an technical and administrative viewpoint, feel free to write them down also.


title: iPhone development options for the [from-my-cold-dead-hands] C developer

text: Please forgive the humor of the title but it certainly gets my point across. I am quite familiar with C code, I can write it in my sleep and after reading through a few tutorials on iPhone development and Objective-C, I'm beginning to feel like I'd rather avoid Obj-C at all costs. It's not that it's unlearnable or "hard". I just don't like it and after reading through many of the Pros and Cons of Objective-C vs. straight C, I've determined that if I need to write an iPhone App, I want to write as much of it as C as is possible. With that said, what is the minimum amount of Objective-C that I need to be aware of or potentially write to be able to create an iPhone app? If I can't write an app 100% in C, then is there a good reference that discusses writing iPhone Apps in C and only discusses the minimal amount of Objective-C logic that needs to be written to get an application to compile and run? Also, is there any good reason why I should learn Objective-C if I don't have to use it for a C project? Specifically, are there times when Objective-C may provide a more optimal coding solution to a problem because of the way the compiler compiles and link the code? I may be a C advocate but more important than that I want to be sure that my application runs as smooth and optimally as possible. **Disclaimer** I am at an early learning stage of a project I may have to work on in the near future. If this process comes to fruition, I'll be getting a Mac as well as a developer license so I'm completely in ignorance. Even worse, _if_ this project is determined to be feasible, I will then be getting the necessary equipment to develop for the iPhone. For now, I'm trying to learn as much information as I can and explore my options. I'd appreciate any (constructive) thoughts, tips and suggestions.


title: When decomposing a large function, how can I avoid the complexity from the extra subfunctions?

text: Say I have a large function like the following:               function do_lots_of_stuff(){              { //subpart 1           ...         }              ...              { //subpart N           ...         }     }      a common pattern is to decompose it into subfunctions               function do_lots_of_stuff(){         subpart_1(...)         subpart_2(...)         ...         subpart_N(...)     }      I usually find that decomposition has two main advantages:   1. The decomposed function becomes much smaller. This can help people read it without getting lost in the details.   2. Parameters have to be explicitly passed to the underlying subfunctions, instead of being implicitly available by just being in scope. This can help readability and modularity in some situations. However, I also find that decomposition has some disadvantages:   1. There are no guarantees that the subfunctions "belong" to do_lots_of_stuff so there is nothing stopping someone from accidentally calling them from a wrong place.   2. A module's complexity grows quadratically with the number of functions we add to it. (There are more possible ways for things to call each other) **Therefore:** Are there useful convention or coding styles that help me balance the pros and cons of function decomposition or should I just use an editor with code folding and call it a day? * * * EDIT: This problem also applies to functional code (although in a less pressing manner). For example, in a functional setting we would have the subparts be returning values that are combined in the end and the decomposition problem of having lots of subfunctions being able to use each other is still present. We can't always assume that the problem domain will be able to be modeled on just some small simple types with just a few highly orthogonal functions. There will always be complicated algorithms or long lists of business rules that we still want to correctly be able to deal with.               function do_lots_of_stuff(){        p1 = subpart_1()        p2 = subpart_2()        pN = subpart_N()        return assembleStuff(p1, p2, ..., pN)     }


title: Looking for an example of how a software project can be managed/deployed

text: My company is evaluating adopting off-the-shelf ALM products to aid in our development lifecycle; we currently use our own homegrown solutions to manage requirements gathering, specification documentation, testing, etc. One of the issues I am having is understanding how to move code between stages of development. We have what we call a pipeline, which consists of particular stops: [Source] -> [QC] -> [Production] At the first stop, the developer works out a solution to some requested change and performs individual testing. When that process is complete (and peer review has been performed), our ALM system physically moves the affected programs from the [Source] runtime environment to the [QC] runtime environment. This movement of code is triggered by advancing the status of the change request to match the stage of the pipeline. I have been searching the internet for a few days trying to find how the process is accomplished elsewhere -- I have read a bit about builds, automated testing, various ALM products, etc. but nowhere does any of this state how builds interact with initial change requests, what the triggers are, how dependencies are managed, how the various forms of testing are accommodated (e.g. unit testing, integration testing, regression testing), etc. Can anyone point me to any resources detailing specific workflows or attempt to explain (generically) how a change could/should be tracked and moved though the development lifecycle? I'd be very appreciative. Note: I've cleaned up the question to hopefully make it easier to understand. Also, I found another question (which I can't find now) that referenced this book, which sounds like it might be exactly what I am looking for -- not sure if I want to shell out the cash for it, though. Additional details per @GlenH7's suggestion: Our products are built with a proprietary language and set of translation tools -- the ultimately runtime environment is similar to a web site architecture, in that we have a bunch of 'code' files sitting out on a server, which our client app accesses on-demand (not unlike a GET request) and then interprets to provide the user experience. We sell an integrated product which is made up of a set of modules (most of which are optional), each module has a team of ~4 programmers and 2 QC testers devoted to the development/bug maintenance. There are around 30 modules per product line (and 3 product lines) -- some teams maintain multiple products lines for their given module. In total, we have 700 employees devoted to development and ~200 programmers. Certainly adopting any new processes or systems is going to involve buy-in, etc. but I'm tasked with simply understanding how the code will be managed so that we can speak intelligently about things. My first task was to learn how to adopt version control into our process (we do not yet use formal version control for most of our product lines, we rely instead of keeping around multiple copies of the entire codebase). We follow the waterfall method pretty closely (which sucks, but the company has been producing software since 1969, so it was probably the natural fit back then and until now, there has been no need to change anything). Some folks are intrigued by the various offerings of the agile methodologies, but as has been noted by @Chad below, we're likely going to need to take incremental steps towards any such end goals (though if we adopt an ALM system, it might be the time to just force a whole new way to do things on everyone). Now for a specific example of our current process, let's say we have a product called HIS, which has an MIS and ITS module (what these are/could be is not important -- think of them as just a collection of files) -- in our current process, if someone requests a change to ITS, a coder will modify some files (effectively) on the development server. When that change needs to be tested, transitioning the status of the change request from 'development needed' to 'qc needed' will trigger our tools to copy the affected files from the development server to the QC server. Now when QC testers signon to the QC testing environment, they will be able to see the effect of the changes. Once they signoff on the change, advancing the status of the request to 'production ready', our tools again copy the code files to the next stage. Once signed off there, a final copy is done to the holding location used for deliveries to customers. We manage delivery of our releases by a major release number (e.g. 6.0) followed by a service release designation (e.g. 5) and a 'priority pack' number (e.g. 1) -- customers take delivery of priority packs, e.g. 6.0.5.1. As stated above, we simply push code from place to place on multiple servers, so we end up with a project folder for each major release and service release throughout the pipeline and end up with a final resting place for each of the ppacks, e.g.:               dev6.0     qc6.0     production6.0          dev6.0.5     qc6.0.5     production6.0.5          ship6.0.5.1      I was thinking that under version control, we could simulate this kind of scheme as:               trunk     branches     --6.0.5     tags     --6.0.5.1      but that seems to cover only half of the locations, i.e. where do the qc and production sources live? Would I create a separate trunk for each major and minor release of the product? Or would I rely on something outside of version control (e.g. the ALM system) to track the revision(s) interesting for testing done at the QC and production stops? We'd need a runtime environment for each, still, but that could be 'built' on-demand as bug fixes and features are made available -- which reinforces the idea that I need not keep any special 'copy' of these stages under version control (they are simply references to revision history of the trunk or branch). Another thing that has thrown me for a loop as that a colleague is pretty adamant that you should not persist anything in branches, i.e. the branch folders should be ephemeral and used only during large changes that can't be committed directly to the trunk (with the expectation that the branch will eventually be merged into the trunk). In his scheme, the minor releases would necessitate a separate top-level with it's own set of trunk, branches and tags, e.g.:               product6.0     trunk     branches     --silly_new_feature     tags     --6.0.5          product6.0.5     trunk     branches     --crazy_bug_fix     tags     --6.0.5.1      (sorry for the delay on adding these details -- got pulled away to meetings all day)


title: How far back do you use your version control and for what reason?

text: Typically when i work on a project i only go back a few days or the last major change when i decide to do something drastic. I sometimes notice i broke a test or a feature and overlooked it for a few weeks so i may go back a month or two and see if the feature or test is broken and trace down the week i broke it. Then find what change did it. On a long term project over the span of a year. Do you actually go back 6+ months and if so why?


title: Design pattern for an automated mechanical test bench

text: **Background** I have a test fixture with a number of communication/data acquisition devices on it that is used as an end of line test for a product. Because of all the various sensors used in the bench and the need to run the test procedure in near real-time, I'm having a hard time structuring the program to be more friendly to modify later on. For example, a National Instruments USB data acquisition device is used to control an analog output (load) and monitor an analog input (current), a digital scale with a serial data interface measures position, an air pressure gauge with a different serial data interface, and the product is interfaced through a proprietary DLL that handles its own serial communication. **The hard part** The "real-time" aspect of the program is my biggest tripping point. For example, I need to time how long the product needs to go from position 0 to position 10,000 to the tenth of a second. While it's traveling, I need to ramp up an output of the NI DAQ when it reaches position 6,000 and ramp it down when it reaches position 8,000. This sort of control looks easy from browsing NI's LabVIEW docs but I'm stuck with C# for now. All external communication is done by polling which makes for lots of annoying loops. I've slapped together a loose Producer Consumer model where the Producer thread loops through reading the sensors and sets the outputs. The Consumer thread executes functions containing timed loops that poll the Producer for current data and execute movement commands as required. The UI thread polls both threads for updating some gauges indicating current test progress. **Unsure where to start** Is there a more appropriate pattern for this type of application? Are there any good resources for writing control loops in software (non- LabVIEW) that interface with external sensors and whatnot?


title: Bringing in New Architecture During Maintenance on Legacy Systems

text: I have been tasked with adding some new features to a legacy ASP.NET MVC2 project. The codebase is a disaster and I want to write these new features with some thought behind the implementation and not just throw these new features into the mess. I would like to introduce things like dependency injection and the orchestrator pattern; just to the code that I am going to write. I don't have enough time to try to refactor the entire system. Is it OK to not be consistent with the rest of the codebase and add new features following different design principles? Should I not introduce new patterns and just get the features implemented? I feel like it might be confusing to the next person to see parts of the system using a design that other parts are not following.


title: What are the arguments for/against Code Generation?

text: I'm in a position where we've got some brittle code that constructs SQL-like queries via text concatenation with parameters for inputs. The data source that it queries is fast and scalable but lacking tool support. Over time, addition entities and properties have been added to the data source that need changing or have obsoleted others, so the queries need changing. I can see that this will happen again in a few months and then again. In order to reduce errors introduced into the text queries, I suggested writing the queries into a separate e.g. .SQL file and then running some kind of code generator tool that could get the schema from the data source and generate a code wrapper around the SQL-like query which was easy to re- generate at any time and would give compile errors for any out-of-date client code. This idea was met with some skepticism and resistance, even when I offered to fund the development myself. What are the reasons against doing this? and, for balance, the reasons to go ahead and do it? (I already saw this post with a couple of answers, but its' not comprehensive)


title: Name for the process of prototype evolution

text: I'm looking for a commonly used name for the process of developing a child object from a parent object, either through clone-and-modify techniques or through the prototypal inheritance mechanisms available in a language like JavaScript. In _JavaScript: The Good Parts_ , Douglas Crockford uses the method name _beget_ for this procedure. That seems a bit too graphic for my tastes, and I've not seen it used elsewhere. ECMAScript 5 and some frameworks just use the method name _create_. E.G. _Take care when_ **———** _prototype X not to override this attribute._ My ideas are _evolving_ , which feels sort of pretentious, and _adapting_ , which just seems vague. _Deriving_ might work, but might also be confusing since it is commonly used when discussing classical inheritance. The term _extending_ might be applicable, but seems to imply that the original object is being modified, which is not the case here. Underscore.js seems to make this available via e.g. `_(o).chain().clone().extend(o2)`. Is there a succinct and widely used term for this procedure?


title: Why are strings so slow?

text: Ever since my very first programming class in high school, I've been hearing that string operations are slower -- i.e. more costly -- than the mythical "average operation." Why makes them so slow? (This question left intentionally broad.)


title: Scala: From concept to working

text: Second attempt to ask my question more concisely. I want to say I am a Scala fan, or at least I want to be. I've resigned myself to learning one of these functional languages [Scala, Haskell, Erlang]. I've dabbled in all of them, far and away I have spent the most time trying to understand Scala. I've honestly used the tutorials for Haskell and Erlang more as a tool for greater understanding in Scala. I do believe that I have on some level an understanding of the basics. But, the reason why I thought I wanted to go with Scala is proving to be the most fustrating ... The verboseness of most Java libraries are ... umm yeah, SNMP4j makes me want to rip my hair out. So here we go, does anyone know of a site or tutorial similar to "Write Yourself a Scheme in 48 hours." Something that really shows how you go from concept to working project including interpreting some third party libraries. Or is Scala truthfully just a better Java? Meaning that it's best to learn Java before attempting Scala. * * * I didn't mean to infer that Scala wasn't a language in it's own right. On the contrary, I feel that it is a very good language; however, the bill of sale for Scala _IS_ that it is better at Java than Java. So I am really trying to answer for myself how viable it is to learn Scala, while I really don't have much of an interest in learning a lot of Java. I want to use the libraries since there is the biggest advantage, as perceived by some, in using Scala. If some of these library implementations are so 'complex' that they require, not just are best benefited by, having a good grasp of Java programming idioms, then I would like to know that I've been approaching this problem from the wrong direction. I realize there are some good examples of some libraries that have been 'scalifed' or what have you.


title: Is it a good idea to dynamically position and size controls on a form or statically set them?

text: I've worked mostly with interface building tools such as xCode's Interface Builder and Visual Studio's environment to place forms and position them on screens. But I'm finding that with my latest project, placing controls on the form through a graphical interface is not going to work. This more has to do with the number of custom controls I have to create that I can't visually see before hand. When I first tackled this, I began to position all of my controls relative to the last ones that I created. Doing this had its own pros and cons. On the one hand, this gave me the opportunity to set one number (a margin for example) and when I changed the margin, the controls all sized correctly to one another (such as shortening controls in the center while keeping controls next to the margin the same). But this started to become a spiders-web of code that I knew wouldn't go very far before getting dangerous. Change one number and everything re sizes, but remove one control and you've created many more errors and size problems for all the other controls. It became more surgery then small changes to controls and layout. Is there a good way or maybe a preferred way to determine when I should be using relative or absolute positioning in forms?


title: Does having a higher paid technical job mean you do not get to code any more?

text: I work at a large company where technical people fall roughly in one of these categories:   1. A **developer** on a scrum team who develops for a single product and maybe works with other teams that are closely related to the product.    2. An **architect** who is more of a consultant on multiple teams (5-6) and tries to recognize commonalities between team efforts that could be abstracted into libraries (architects do not write the library code, however). This architect also attends many meetings with management and attempts to set technical direction. In my company the architect role is where most technical people move into as the next step in their career. My questions are: Do most companies work such a way that their highest paid technical people are far removed from writing code? Is this a natural tendency for a developer's career? Can a developer have it all (code AND set direction?)


title: How can I test database access methods in Java?

text: I want to write a test for a method that accesses a database such as following.               public class MyClass{         public String getAddress(Int id){             String query = "Select * from Address where id="+id;             //some additional statements                        resultSet = statement.executeQuery();             return result.getString(ADDRESS);                 }     }      How can I test this method? I am using Java.


title: What problems can happen if an XML file is not backed by a schema?

text: What is a XML schema in plain simple terms? What will be the problem if an XML doesn't have a schema defined? An example can be very helpful.


title: Where to draw the line between front end and back end

text: I was recently contracted to develop a smarty theme for an automated SOHO phone answering service. The team who had built the backend wouldn't allow me access to any of the back end nor tell me anything about it, their smarty set up, smarty plugins, data base interface api, server set-up, nothing. Nor could I have access to the server nor a beta domain, basically zero co-operation. So I set up a local server with Smarty and built the template based on what I guessed would be their best practice, commented my code like crazy, wrote all the needed javascript, css, and template files. Then I sent them packaged to the backend team and hoped for the best. With half of a project team failing to cooperate or even communicate I am now concerned that they may reply saying that everything is wrong and they may refuse to implement the new front end. I'm curious to know if others encounter this type of situation and what you may have done to protect yourselves.


title: Send stdout or stderr to a new thread

text: For performance issue I want the logging send to a new thread. While the main program can work, the new thread can write the error or other messages to a file without effect to the main program. How could I send all stdout to the new thread? Work to be done:   * create a new thread, ok   * open a file, ok   * create a pipe inside the thread, ok   * send stdout to the new thread, with freopen or dup? Every time the buffer gets full, or every 5 seconds the log file gets new data. Because it is an MPI program, I can't fork the whole program. It has to be a Posix thread.


title: What are the responsibilities of a Manager and of the Dao Layers

text: In several projects we have been using the following layers:   1. Action (has 1 or more managers)   2. Manager(has 1 or more Daos)   3. Dao But most of the time the manager only calls the dao. We do use the manager class to prepare the date to be sent to the db or to prepare the data to be sent to the action(is this a good practice?).   1. What are the responsibilities of a Manager and of the Dao classes?   2. Do we have to have a manager for every dao or can we just use the dao directly?   3. How do I handle situations where I need to use the functionality implemented in several Managers? PS: I know that there is no golden hammer so I'll narrow it to the types of apps we do, generally webapps for banks. Thank you


title: Best method for async initialization of view model in MVVM pattern (WPF)

text: I'm working on a business application (C#, WPF, EF, MVVM). I need to load a bunch of items from database, create view models for them and put them in a window. Is there a way to create the view model in another thread or do something similar to speed up UI?   1. The approximate average time needed to fetch all items from database = 1s    2. The approximate average time needed to instantiate all view models = 3s I'm doing the first part through Loaded event of each item. but the second part is the bottleneck. any insight would be appreciated.


title: What is the best practice for refactoring a static method in order to make it more testable?

text: Let's say you have a static method that looks something like this:               public static bool Foo()     {          var bar = new Bar();         //do some stuff here     }      This method as it stands can be a real headache to unit test. What is the best practice to refactor this so that it can be testable, without turning it into an instance method or changing the method signature?


title: When to build User Controls in ASP.NET

text: I am inheriting a legacy code. The legacy code has lot of web forms and each web form does not have much of functionality other than hosting a user control. My question is -   * Should we create a user control even if that control is not used in any other web form ?   * Are there any hard benefits in creating user controls over web forms? P.S - Web forms are .aspx files and User Controls are .ascx files.


title: At ping, why do we have to do array copying instead of passing on the source array that the client sent to us?

text: So I have been googling about this OpenSSL heart-bleed thing and somehow sees that it is caused by the heartbeat extension which requires client to ping the server to show its aliveness and it all comes to this memcpy function in C which is meant to copy from the source array to the destination array with the user specified size. If the size was a lie (which means the source contains lesser byte than the size claims) then memcpy will grab the arbitrary memory around and allocated to the destination and in this case send back to the client… Reference: Anatomy of OpenSSL's Heartbleed: Just four bytes trigger horror bug > `payload` is controlled by the attacker, and it's quite large at 64KB. If > the actual `HeartbeatMessage` sent by the attacker only has a payload of, > say, one byte, and its payload_length is a lie, then the above `memcpy()` > will read beyond the end of the received `HeartbeatMessage` and start > reading from the victim process's memory... If my understanding above is correct, then I have a question here maybe naive one, why do we have to do array (char array here) copying here? Can't we just pass on the source char array that the client sent to us? i.e. If you send me               function(char[] array)      Then I would just need to send back that very array               send(array)


title: Should Agile teams deliver new features daily?

text: My company is in the midst of a transition from waterfall-style development to Agile/Scrum. Among other things, we're told that the expectation is for us to have **new** working, **testable** (by QA) features at the end of each day. Most of our devs lose around 2 hours a day to meetings and other enterprisey overhead. This means that in any given 6-hour (at best) period, we have to design, write, unit-test, build, and deploy (with release notes) enough code to produce a complete feature for QA to play with. I understand that the build/deploy/release notes could be automated with a proper CI setup but we're not there yet. We also have a large offshore contingent writing our server-side code, and the 12-hour time difference makes this even more difficult. We attempt to task out stories into narrow, deep vertical slices in order to complete features end-to-end as fast as possible, but most days feel rather frantic and I often catch people taking stupid, fragile shortcuts to ensure QA has their build. This problem is compounded after a sprint has been in progress for a couple of days, when the inevitable defects start rolling in and have to fit into the same 6-hour window. Is this a normal pace for Agile teams? Even if we manage to implement a CI setup, I can't see how we'll be able to sustain this pace and still create quality software. **Edit:** There are several good answers here. It made me realize that what I was really asking is, should Agile teams deliver **new features** daily. I updated the title accordingly.


title: Teaching myself, as a physicist, to become a better programmer

text: I've always liked physics, and I've always liked coding, so when I got the offer for a PhD position doing numerical physics (details are not relevant, it's mostly parallel programming for a cluster) at a university, it was a no- brainer for me. However, as most physicists, I'm self taught. I don't have broad background knowledge about how to code in an object oriented way, or the name of that specific algorithm that optimizes the search in some kD tree. Since all my work so far has been more concerned about the _physics_ and the scientific results, I undoubtedly have some bad habits - more so because my coding is my own, and not really teamwork. I have mostly used C since it is very straightforward and "what you write is what you get" - no need for fancy abstractions. However, I have recently switched to C++ since I'd like to learn more about the power that comes with abstraction, and it's pretty C-like (syntax-wise at least). How do I teach myself to code in a good, abstract way like a graduate in computer science? I know my code is efficient, but I want it to be _elegant_ as well, and readable. Keep in mind that I don't have time to read several 1000-page tomes about abstract programming. I need to spend time on actual, physics related research (my supervisor would laugh at me if he knew I spent time thinking about how to program elegantly). How do I assess if my work is also good from a programmer's perspective?


title: Android development & hardware testing - Which handsets & tests? What are the best options/deals?

text: I'm quite new to Android development. I spent a few weeks, doing tutorials and developping simple apps. Now, I'm focusing on all the test aspects. I have done Junit tests before so I thought it would be OK but now I'm slightly worried about the test coverage required. First, how to test with hardware with that many different devices?? I though I would just buy one but now I'm not so sure. There are so many handsets and they are so different! hardware feature missing, different resolutions, different lib version, etc Have you guys got statistics about which handset sell the best per country? So that we can just buy the 2,3 most representative phones? Is there any developer deals where you buy 3 phones + 1 contract for a reasonable price (I'm in the UK btw). Also, to go back to emulator tests, is there a way to kind of convert a famous handset into the corresponding AVD? Is there some nice free test infrastructure available that make multi-AVDs, multi-config, multi-projects test easier? Now I know most of the programs such as adb,android,emulator, etc... Still will probably need to write some python scripts which integrate them all.. Anyway, I'm slightly puzzled here so any pointer, any comment about your own android test strategy would be much appreciated! Thanks in advance Mikael


title: How should a website validate a users mailing address?

text: This is for a site that relies on shipping items via UPS or FedEx. I know there is software out there that does it (http://en.wikipedia.org/wiki/Coding_Accuracy_Support_System), but if you are trying to build your own solution for a simple website.


title: Business Analyst role in development process

text: I work as a business analyst and I currently oversee much of the development efforts of an internal project. I'm responsible for the requirements, specs, and overall testing. I work closely with the developers (onshore and offshore). The offshore team produces all of the reports. Version 1.0 had a 9 month development cycle and I had about 4-5 months to test all the reports. There was the usual back and forth to get the implementation right. Version 2.0 had a much shorter development cycle (3 months). I received the first version of the reports about 3 weeks ago and noticed a lot of things wrong with it. Many of the requirements were wrong and the performance of the queries was horrendous at 5x - 6x longer than it should have been. The onshore lead developer was out and did not supervise the offshore development team in generating the reports. Management knew about the performance issues and I also told them I was trying to find a way to improve performance; they did not explicitly approve of sending test queries, but they were also not concerned with the fact I was doing that. I took a look at the SQL in the reports and was able to improve performance greatly (by a factor of 6x) which is acceptable for this version. I sent the updated queries as guidelines to the offshore team and told them they should look at doing X instead of Y to improve performance and also to fix some specific logic issues. I then spoke to my managers about this because it doesn't feel right that I was developing SQL queries, but given our time crunch I saw no other way. We were able to fix the issue quite fast which I'm happy with. Current situation: the onshore managers aren't too pleased that the offshore team did not code for performance. I know there are some things I could have done better throughout this process and I do not in any way consider myself a programmer. **My question is, if an offshore team that works apart from the onshore project resources fails to deliver an acceptable release, is it appropriate to clean up their work to meet a deadline? What kind of problems could this create in the future?** Update: So far management is upset with the offshore team, but have not "reprimanded" me in any way, so I'm not sure in their eyes if what I did was wrong, but I think their main source of frustration was the offshore team was not able to come up with a solution and I was, especially since this sort of performance issue had come up in the past. I am not defending my actions, but I want to give context so that the picture is a little clearer. I accepted the answer that most criticizes my actions I agree it's not something that should be done by someone in my position.


title: How is the build for a msdeployment project different than a regular web application project?

text: In our CI environment we build all the cs projects and then build the deployment projects. The deployment projects do an extra step of compiling the aspx & ascx files and often catch errors that would normally be caught at run time. 1) Is there a name for this step or process?   2) Can I get it in the regular project builds?   3) Where can I learn about the various steps of building specifically to msbuild?      Reading the logs in verbose I'd like to have a better understanding of what is actually happening. Thank you.


title: Declaring variables in Python and PHP

text: The question is how to cope with absence of variable declaration in Python, PHP, and the like. In most languages there is a way to let the compiler know whether I introduce a new variable or refer to an existing one: `my` in Perl (`use strict`) or `\newcommand` vs. `\revewcommand` in LaTeX. This prevents from two major sources of errors and headache: (1) accidentally using the same name of a variable for two different purposes, such as in (PHP)               $v = $square * $height;     <...lots of code...>     foreach ($options as $k => $v)         echo "For key $k the value is $v\n";     <...lots of code...>     echo "The volume is $v";      or a lot nastier (PHP)               $a = [1, 2, 3];     foreach ($a as $k => &$v)         $v++;     foreach ($a as $k => $v)         echo "$k => $v\n";      (can you see a bug here? try it!); and (2) prevent from typos (PHP):               $option = 1;     $numberofelements = 1;     if ($option)     {         $numberofelenents = 2;     }     echo $numberofelements;      (can you see a bug here? PHP will execute silently). Using something like `my` (Perl)               use strict;      my $option = 1;     my $numberofelements = 1;     if ($option)     {         $numberofelenents = 2;     }     say $numberofelements;      (Perl will immediately report the bug) is a tiny effort and HUGE benefit both in debug time and (much more importantly) in losses (potentially huge) from incorrect programs. However, some languages, notably Python, PHP, and JavaScript, do not give any protection from these types of bugs. My question is how can we effectively cope with this? The only way I can foresee is to create two functions (PHP):               function a ($x)     {         if (isset ($x))             die();         else             return &$x;     }      and               function the ($x)     {         if (isset ($x))             return &$x;         else             die();     }      and use them always:               a($numberofelements) = 1;     the($numberofelenents)++;     say the($numberofelements);      but of course this is extremely cumbersome. Any better way of effectively protecting from such errors? No, "use another language", "be careful and don't make errors", and "split your code in tiny functions" are not good answers (the latter may protect from the errors of type 1 but not type 2).


title: How do you balance the speed of Sprints with the customer's conservative adoption schedule?

text: I'd prefer to have sprints that last 3-4 weeks, but customers don't want to adopt new feature/function every 3-4 weeks. Existing customers are conservative and, once we meet their minimum bar for features and capabilities, they like to remain on a stable release for much longer than 4 weeks. Even a 3-month cycle would be pushing it for them. On the other hand, newer customers tend to have more feature requests, and are willing to follow sprints. But this willingness dissipates after we've met their bar. How do you balance the need for rapid sprints with the customer's conservative view of application change? I'm particularly interested in SaaS scenarios.


title: OAuth2 flow - does the server validate with the Auth server?

text: I've been reading a lot on OAuth2 trying to get my head around it, but I'm still confused about something. I understand that the client authorises with the OAuth provider (google for example) and allows the resource server to have access to the user's profile data. Then the client can send the access token to the resource server and be given back the resource. But what does not seem to be covered in any of the documentation is what happens when the client app asks the resource server for a resource and passes it the access token. Everything I have read so far states that the resource server just responds with the requested resource. But that seems like a huge hole, surely the resource server must somehow validate the access token, otherwise I could just fake up any old request and pass an old, stoken, fake, or randomly generated token and it would just accept it. Can anyone point me at a simple to follow explanation of OAuth2 because so far the ones I have read feel imcomplete. Thanks


title: Is it better to put an event on the top object or closer to where it's local?

text: Take the following basic structured code for example:               class Player     {        public QuestLog QuestLog { get; set; }     }      Let us consider that "QuestLog" has the ability to fire off some events when things are added or removed from it. Normally, I would subscribe directly to the QuestLog, such as doing something like:               player.QuestLog.AcceptedQuest += SomeHandler      However, I want to pass in some extra context (the player object). I saw a couple options.   1. Creating a lambda handler function which can resolve an extra parameter to the handler. This works but has some quirks I don't like. I'm currently using this approach.   2. I could couple the QuestLog to a Player, passing a reference of the player it belongs to in and fire events off accordingly with it. Feels like needless coupling.   3. Expose the event on the Player object itself as well as the QuestLog and 'bubble' the event up into where the context is available, thus allowing subscriptions directly onto player. Keep in mind a player may have a few collections and a few events, so moving them all up might cause a couple dozen events to be held on one class. How is this usually handled?


title: Why is C++ predominant in programming contests and competitions?

text: I understand that C++ is a very fast language, but ain't C just as fast, or faster in some cases? Then you might say that C++ has OOP, but the amount of OOP you need for most programming puzzles is not that big, and in my opinion C would be able handle that. **Here's why I am asking this** : I am very interested in programming contests and competitions, and I am used to coding in C on those. However, I noticed that the vast majority of people use C++ (e.g., 17 out of 25 finalists on Google Code Jam 2011 used it, while no one used C), so I am wondering if I am at a disadvantage going with C. Apart from the Object Orientation, what makes C++ a more suitable language for programming competitions? What are the features of the language I should learn and use to perform better on the competitions? For background, I consider myself pretty proficient in C, but I am just starting to learn C++.


title: Significance and role of Node.js in Web development

text: I have read that Node.js is a server-side javascript enviroment. This has put few thought and tinkers in my mind. Can we develop a complete data-drivent web application utilizing just JavaScript (along with node.js), HTML5 and CSS? Do we still need to use some server-side scripting language (e.g. C#, PHP)? In case we still need to use other scripting languages, what is node.js worth for, or useful? **NOTE:** _Pardon with my knowledge about node.js._


title: Problem with C code. Raspberry PI, HD44780 LCD

text: I have been writing a program for interfacing a raspberry pi with a HD44780 LCD. The code I have wrote does not seem to initialise the display, from the datasheet as far as I can tell I am doing the correct process. I know the code is not great but I am just focusing on getting it working then tidying it up and such. This is to help me learn C. I am using the bcm2835 library from mikem. The code is as follows:               #include <stdio.h>     #include <bcm2835.h>          #define RS RPI_GPIO_P1_26 //GPIO 7     #define En RPI_GPIO_P1_24 //GPIO 8     #define D4 RPI_GPIO_P1_11 //GPIO 17     #define D5 RPI_GPIO_P1_12 //GPIO 18     #define D6 RPI_GPIO_P1_13 //GPIO 27     #define D7 RPI_GPIO_P1_15 //GPIO 22          #define FUNC_4b_2L_5X8 0x28     #define DISP_ON_CURS_ON_BLINK_OFF 0x0E     #define INC_ON_SHIFT_OFF 0x06     #define CNTRL_LINES_LOW 0xFFF8     #define CURS_LEFT 0x10     #define CURS_RIGHT 0x14     #define CLR_DISP 0x01     #define SHIFT_LEFT 0x18     #define SHIFT_RIGHT 0x1C     #define ROW_0_START 0x80     #define ROW_1_START 0xC0     #define RETURN_HOME 0x2                    void lcd_gpio_low(void)     {         bcm2835_gpio_write(RS, LOW);         bcm2835_gpio_write(En, LOW);         bcm2835_gpio_write(D4, LOW);         bcm2835_gpio_write(D5, LOW);         bcm2835_gpio_write(D6, LOW);         bcm2835_gpio_write(D7, LOW);     }          void assign_bits(uint8_t data)     {         switch(data)         {             case 0:                 bcm2835_gpio_write(D4, LOW);                 bcm2835_gpio_write(D5, LOW);                 bcm2835_gpio_write(D6, LOW);                 bcm2835_gpio_write(D7, LOW);                 break;                  case 1:                 bcm2835_gpio_write(D4, HIGH);                 bcm2835_gpio_write(D5, LOW);                 bcm2835_gpio_write(D6, LOW);                 bcm2835_gpio_write(D7, LOW);                 break;                  case 2:                 bcm2835_gpio_write(D4, LOW);                 bcm2835_gpio_write(D5, HIGH);                 bcm2835_gpio_write(D6, LOW);                 bcm2835_gpio_write(D7, LOW);                 break;                  case 3:                 bcm2835_gpio_write(D4, HIGH);                 bcm2835_gpio_write(D5, HIGH);                 bcm2835_gpio_write(D6, LOW);                 bcm2835_gpio_write(D7, LOW);                 break;                  case 4:                 bcm2835_gpio_write(D4, LOW);                 bcm2835_gpio_write(D5, LOW);                 bcm2835_gpio_write(D6, HIGH);                 bcm2835_gpio_write(D7, LOW);                 break;                  case 5:                 bcm2835_gpio_write(D4, HIGH);                 bcm2835_gpio_write(D5, LOW);                 bcm2835_gpio_write(D6, HIGH);                 bcm2835_gpio_write(D7, LOW);                 break;                  case 6:                 bcm2835_gpio_write(D4, LOW);                 bcm2835_gpio_write(D5, HIGH);                 bcm2835_gpio_write(D6, HIGH);                 bcm2835_gpio_write(D7, LOW);                 break;                  case 7:                 bcm2835_gpio_write(D4, HIGH);                 bcm2835_gpio_write(D5, HIGH);                 bcm2835_gpio_write(D6, HIGH);                 bcm2835_gpio_write(D7, LOW);                 break;                  case 8:                 bcm2835_gpio_write(D4, LOW);                 bcm2835_gpio_write(D5, LOW);                 bcm2835_gpio_write(D6, LOW);                 bcm2835_gpio_write(D7, HIGH);                 break;                  case 9:                 bcm2835_gpio_write(D4, HIGH);                 bcm2835_gpio_write(D5, LOW);                 bcm2835_gpio_write(D6, LOW);                 bcm2835_gpio_write(D7, HIGH);                 break;                  case 10:                 bcm2835_gpio_write(D4, LOW);                 bcm2835_gpio_write(D5, HIGH);                 bcm2835_gpio_write(D6, LOW);                 bcm2835_gpio_write(D7, HIGH);                 break;                  case 11:                 bcm2835_gpio_write(D4, HIGH);                 bcm2835_gpio_write(D5, HIGH);                 bcm2835_gpio_write(D6, LOW);                 bcm2835_gpio_write(D7, HIGH);                 break;                  case 12:                 bcm2835_gpio_write(D4, LOW);                 bcm2835_gpio_write(D5, LOW);                 bcm2835_gpio_write(D6, HIGH);                 bcm2835_gpio_write(D7, HIGH);                 break;                  case 13:                 bcm2835_gpio_write(D4, HIGH);                 bcm2835_gpio_write(D5, LOW);                 bcm2835_gpio_write(D6, HIGH);                 bcm2835_gpio_write(D7, HIGH);                 break;                  case 14:                 bcm2835_gpio_write(D4, LOW);                 bcm2835_gpio_write(D5, HIGH);                 bcm2835_gpio_write(D6, HIGH);                 bcm2835_gpio_write(D7, HIGH);                 break;                  case 15:                 bcm2835_gpio_write(D4, HIGH);                 bcm2835_gpio_write(D5, HIGH);                 bcm2835_gpio_write(D6, HIGH);                 bcm2835_gpio_write(D7, HIGH);                 break;         }     }          void pulse_enable_line(void)     {         bcm2835_gpio_write(En, HIGH);         bcm2835_delayMicroseconds(1);              bcm2835_gpio_write(En, LOW);         bcm2835_delayMicroseconds(1);     }          void send_nyble(uint8_t data)     {         assign_bits(data);         bcm2835_delayMicroseconds(10);              pulse_enable_line();     }          void send_byte(uint8_t data)     {         send_nyble(data >> 4);         bcm2835_delayMicroseconds(10);              send_nyble(data & 0x0F);         bcm2835_delayMicroseconds(10);     }          void write_inst(uint8_t data)     {         lcd_gpio_low();         bcm2835_delayMicroseconds(1);         send_byte(data);         bcm2835_delayMicroseconds(10);     }          void clear_disp(void)     {         // Clear display         write_inst(CLR_DISP);         bcm2835_delayMicroseconds(40);     }          void write_data(uint8_t data)     {         bcm2835_gpio_write(RS, HIGH);         send_byte(data);         bcm2835_delay(5);         bcm2835_gpio_write(RS, LOW);     }          // Displays character, pass in a character      void disp_char(char *text)     {         // Set all outputs to 0         lcd_gpio_low();         // Set RS to 1         bcm2835_gpio_write(RS, HIGH);         bcm2835_delayMicroseconds(1);         // Set the passed in value          send_byte(*text);         bcm2835_delayMicroseconds(40);         // Set all outputs to 0         lcd_gpio_low();         bcm2835_delayMicroseconds(40);      }                    void lcd_init(void)     {         //Set lines as outputs         bcm2835_gpio_fsel(RS, BCM2835_GPIO_FSEL_OUTP);         bcm2835_gpio_fsel(En, BCM2835_GPIO_FSEL_OUTP);         bcm2835_gpio_fsel(D4, BCM2835_GPIO_FSEL_OUTP);         bcm2835_gpio_fsel(D5, BCM2835_GPIO_FSEL_OUTP);         bcm2835_gpio_fsel(D6, BCM2835_GPIO_FSEL_OUTP);         bcm2835_gpio_fsel(D7, BCM2835_GPIO_FSEL_OUTP);              lcd_gpio_low();              bcm2835_delay(42);                   // Send function set data as 8 bits, 2 lines and 5x8         write_inst(FUNC_4b_2L_5X8);              bcm2835_delay(5);              // Send function set data as 8 bits, 2 lines and 5x8         write_inst(FUNC_4b_2L_5X8);              bcm2835_delayMicroseconds(110);              // Send function set data as 8 bits, 2 lines and 5x8         write_inst(FUNC_4b_2L_5X8);         bcm2835_delayMicroseconds(40);              // Send function set data as 8 bits, 2 lines and 5x8         write_inst(FUNC_4b_2L_5X8);         bcm2835_delayMicroseconds(40);              // Send Display control. Disp on, cursor on and blinking off         write_inst(DISP_ON_CURS_ON_BLINK_OFF);         bcm2835_delayMicroseconds(40);              // Send Entry mode set. Increment on, shift off         write_inst(INC_ON_SHIFT_OFF);         bcm2835_delayMicroseconds(40);              // Clear Display         clear_disp();     }          int main()     {         //bcm2835_set_debug(1);              if (!bcm2835_init())             return 1;              lcd_init();              write_data(0x48);              printf("%d",'F');              bcm2835_delay(10000);              return 0;     }


title: Slow if use object cross referecing

text: In OOP, it seems that if an object cross-references another object in its property, ultimately, if such objects are used a lot, the software at the end will be slow because of this. Is this true? If yes, can we intentionally not do this by getting things done?


title: When to pay for C++ compilers

text: Recently I have began to wonder when developers should pay for compilers. Compilers come for free with most platforms or there is a free version easily obtainable. Example: OS X - GCC and Clang/LLVM come with the developer tools. No limitations here for how and what you can turn out with them. Linux - GCC and I am sure more. I dont know the current state of linux compilers. No limitations here for how and what you can turn out with them. Windows - MinGW and Microsoft does offer a free version of Visual Studio. No limitations with MinGW but I think with the free Visual Studio there are severe limitations. However, as an example, Intel produces C/C++ compilers. They are hefty in price. Educationally I think that one can get the OS X version for $49 and Windows/Linux for $129 each. They then offer a complete "Studio" product too. Obviously using the educational pricing there are imposed limitations. But what I am wondering is when should one really considering paying for compilers. One example I can think of is a video game. If you are using a compiler that works on the major platforms there would be no more switching tools for the platform. It seems there would be a level of ease in switching among platforms if the tools were the same. Can anyone shed some light on paying for compilers like the Intel compilers and the true cross-platform benefits one might get from using them? Does one's code become less portable even trying very hard to not do platform specific techniques?


title: What are general best practices for plugin/extension development?

text: I need to correlate requirements for a plugin/extension of an application with development best practices. I thought there might be best practice advice that applies to plugins and extensions available but cannot find any literature. Of course best practices are often common sense, but my task involves applying a framework to describe design choices. If any resources specific to plugins/extensions are known that would be great. Otherwise, I would like, to at least find a well respected language agnostic list of software development principles.


title: Global request context - anti-pattern?

text: I was talking today to a colleague of mine about Python web frameworks and our impressions about them. I told him I think Flask having a global request smells badly and is an anti-pattern. The docs say about request context: > In contrast, during request handling, a couple of other rules exist: > >   * while a request is active, the context local objects (flask.request and > others) point to the current request. >   * any code can get hold of these objects at any time. > I think I understand the idea behind this design decision -- to make the application simpler. It's just a compromise, like in the case of Thread Locals: > Yes it is usually not such a bright idea to use thread locals. They cause > troubles for servers that are not based on the concept of threads and make > large applications harder to maintain. However Flask is just not designed > for large applications or asynchronous servers. Flask wants to make it quick > and easy to write a traditional web application. Is patching a global object with the current request information an anti- pattern? I believe it is, because it is in the view of static code analyzer a global state, though it's not. And I as a programmer will not understand how it works without reading the docs carefully. And this has consequences on tests. Isn't it a good practice to pass the request as an argument to views? I think it's more readable, explicit and easier to debug. And avoids global state.


title: Writing Acceptance test cases

text: We are integrating a testing process in our SCRUM process. My new role is to write acceptance tests of our web applications in order to automate them later. I have read a lot about how tests cases should be written, but none gave me practical advices to write test cases for complex web applications, and instead they threw conflicting principles that I found hard to apply:   * **Test cases should be short:** Take the example of a CMS. Short test cases are easy to maintain and to identify the inputs and outputs. But what if I want to test a long series of operations (eg. adding a document, sending a notification to another user, the other user replies, the document changes state, the user gets a notice). It rather seems to me that test cases should represent complete scenarios. But I can see how this will produce overtly complex test documents.   * **Tests should identify inputs and outputs:** : What if I have a long form with many interacting fields, with different behaviors. Do I write one test for everything, or one for each?   * **Test cases should be independent:** But how can I apply that if testing the upload operation requires that the connect operation is successful? And how does it apply to writing test cases? Should I write a test for each operation, but each test declares its dependencies, or should I rewrite the whole scenario for each test?   * **Test cases should be lightly-documented:** This principles is specific to Agile projects. So do you have any advice on how to implement this principle? Although I thought that writing acceptance test cases was going to be simple, I found myself overwhelmed by every decision I had to make (FYI: I am a developer and not a professional tester). So my main question is: What steps or advices do you have in order to write maintainable acceptance test cases for complex applications. Thank you. **Edit** : To clarify my question: I am aware that Acceptance testing should start from the requirement and regard the whole application as a black box. My question relates to the practical steps to write the testing document, identify the test cases, deal with dependencies between tests...for complex web applications


title: Continuous integration never results in build errors

text: I'm working with a variety of Java EE websites which use internal libraries we've developed. For each website, we only upgrade to new versions of our internal libraries as needed, and before committing we make sure that the site compiles fine. What this means is that when TeamCity does a build of one of our sites, the site compiles fine, but later when the site is updated to the latest version of internal libraries, there might be a compile error. Is there a good way to handle this? We're not using Maven yet; would using Maven mean that our websites could automatically use the latest version of internal libraries? Thanks. **Clarification:** What we sometimes run into is this:   1. Project A depends on a library, and is currently using library version 1.0   2. Project B also depends on that library. I make changes to the library so that it is now version 1.5. Project B now uses 1.5.   3. Project A and project B have both been built just fine by the CI server (TeamCity)   4. Working on project A again, I update to 1.5 and discover that 1.5 has breaking changes in it. Is there a way for the CI server to discover these kinds of breaking changes?


title: How to keep your third party libraries up to date?

text: Let's say that I have a project that depends on 10 libraries, and within my project's trunk I'm free to use any versions of those libraries. So I start with the most recent versions. Then, each of those libraries gets an update once a month (on average). Now, keeping my trunk completely up to date would require updating a library reference every three days. This is obviously too much. Even though usually version 1.2.3 is a drop-in replacement for version 1.2.2, you never _know_ without testing. Unit tests aren't enough; if it's a DB / file engine, you have to ensure that it works properly with files that were created with older versions, and maybe vice versa. If it has something to do with GUI, you have to visually inspect everything. And so on. How do you handle this? Some possible approaches:   * **If it ain't broke, don't fix it**. Stay with your current version of the library as long as _you_ don't notice anything wrong with it when used in your application, no matter how often the library vendor publishes updates. Small incremental changes are just waste.   * **Update frequently in order to keep change small.** Since you'll have to update some day in any case, it's better to update often so that you notice any problems early when they're easy to fix, instead of jumping over several versions and letting potential problems to accumulate.   * **Something in between.** Is there a sweet spot?


title: Is it ever OK to commit non-working code?

text: > Is it good idea to require to commit only working code? This commit doesn't need to leave the repository in a working state as:   * ... we are in early design stages, the code is not yet stable.   * ... you are the sole developer on the project. You know why things aren't working. Furthermore, you are not stopping anyone's work by committing broken code.   * ... the code currently doesn't work. We are going to make a big change to it. Let's commit, in order to have a point to revert to if things get ugly.   * ... the chain is long, no trouble if broken code exists in the local branch. I.e.     1. local files     2. staging area     3. commits in local branch     4. commits in remote personal feature branch     5. merge with remote `develop` branch     6. merge with remote `master` branch     7. merge with remote `release` branch   * ... commit early,commit often. So in the above-linked question, the majority of answers say that committing not-compilable code is no problem in local and feature branches. **Why?** What is the value of a broken commit? * * * Added: There are a couple of highly-voted comments, saying that on a local brach one can do whatever one wants. However, I am not interested in the technical side of the question. Rather, I would like to learn the best practices - the habits, that people who have worked many years in the industry, have hound most productive. * * * I am amazed at the vast amount of great answers! They lead me to the conclusion that I am not adept enough at using **branches** to organize my code.


title: Using Autoincrement Primary keys as Foreign Keys

text: When creating a table, there is an option for us to set the numeric primary key as autoincrement where it's value increases whenever a new data in inserted. This primary number can be used for setting the relationship of a table where it is assigned as a foreign key to that table. So my question is it a good practice for us to use the autoincrement numeric primary as foreign key or should we use the programmatically generated code. **e.g.** for a table 'products' we have the fields 'id' (autoincrement primary key), 'productCode' (program generated unique item code. field property also set to unique), 'Description'. and we are going to create a relationship to a transactions table. What field should be used as foreign key, the 'autoid' or the product code?


title: Is blogging a good platform to get into freelancing from a completely unrelated job?

text: **Quick background** \- I work in a bank doing financial modelling where I need to do some domain specific programming, but otherwise it's only statistics and presentations. **Situation** \- Software has always been my first "love", but due to various circumstances I did not take up a career in the software industry. I have a very good graduate degree in Theoretical Computer Science - so I understand what it means when people talk about traveling salesmen, lambda calculus or whether P=NP (examples). I intend to get into programming full time in the next couple of years. **Chosen path**   1. Get really good at something - I have chosen the HTML5 "ecosystem" comprising HTML, Javascript and CSS. Over the years I have programmed in C, Haskell, Erlang, C++, Javascript, Common Lisp, Basic and Logo but not sufficiently proficient in any of them.   2. Establish myself as an expert in the community primarily through blogging and participating in projects / forums / events related to the same. Then I can try and establish some freelancing business or convince a startup to hire me. **Questions** \- Are there any well known examples of people who have taken a similar path after working in a completely unrelated field for years (7, in my case)? Am I completely delusional and two years is too short a time?


title: What's the web framework to use on a front-end web application?

text: What do you consider a good client web framework to use on interface business application? jQuery? YUI!? Another? Some plugins useful? The application will be use mostly internally replacing a desktop application for data entry and lots of queries/views.


title: why control + alt + delete couldn't be intercepted by any application

text: The secure attention key is designed to make login spoofing impossible, as the kernel will suspend any program, including those masquerading as the computer's login process, before starting a trustable login operation. Why other programs cannot simulate `control + alt + del`? What is stay behind this?


title: What's the next level of abstraction?

text: Since programming languages initially only used lines of code executed sequentially, and it evolved into including functions which were one of the first levels of abstraction, and then classes and objects were created to abstract it even further; what is the next level of abstraction? What's even more abstract than classes or is there any yet?


title: Develop open-source library and get donations for it?

text: I have a nice open-source library in mind to write. It would take a few months to develop properly and I would need to stop supporting myself though other projects. Could anybody share experiences and best-known-methods to get some sort of financial support through the Internet whilst developing free, open- source code? Or, phrased more directly: which systems apart from "PayPal" are in use by programmers to get donations for open-source code? Provide a list. Optionally, sort the list as if it were a recommendation in descending order of positive experiences made with each system. Optionally, share a tidbit of your success story getting this kind of financial support. Optionally: give an indication as to how much money can be made that way? (I heard Vim's author could support himself just with donations at some point?)


title: Why am I seeing so many instantiable classes without state?

text: I'm seeing a lot of instantiable classes in the C++ and Java world that don't have any state. I really can't figure out why people do that, they could just use a namespace with free functions in C++, or a class with a private constructor and only static methods in Java. The only benefit I can think of is that you don't have to change most of your code if you later decide that you want a different implementation in certain situations. But isn't that a case of premature design? It could be turned into a class later, when/if it becomes appropriate. Am I getting this wrong? Is it not OOP if I don't put everything into objects (i.e. instantiated classes)? Then why are there so many utility namespaces and classes in the standard libraries of C++ and Java? **Update:** I've certainly seen a lot examples of this in my previous jobs, but I'm struggling to find open source examples, so maybe it's not that common after all. Still, I'm wondering why people do it, and how common it is.


title: LGPL License in commercial application

text: I have searched around but I don't seem to be able to get a clear answer on my questions that I understand. I want to use the Xuggler library in my application, which is licensed either GPL or LGPL depending on whether I compile it myself. I don't intend to edit the library If I compile it myself and thus get a LGPL version of the library, can I use it in a commercial application without having to distribute the source code of my application? Furthermore, do I have to give my application the LGPL license as well? What other problems might using this library give me?


title: How often should we launch SONAR analysis?

text: I successfully installed Jenkins and then Sonar to go with continuous integration. The firsts reports are not that good in term of rules violations ,comments, code duplication ... I set Jenkins to get java classes, run tests with cobertura and then launch SONAR once every night during week days. I then asked the developers to put some time and effort in correcting rules violations, and try to re-factor the code using SONAR data. However it seems they would like to see their corrections in SONAR almost as they commit them. So I got different choices :   * Let the SONAR launch to once a day   * Allow developers to launch sonar task themselves   * Decrease Jenkins time between builds (like every 1h) 2nd solution : I'm afraid of the number of snapshot that will appear in the SONAR history and the fact that it'll make the "compare since last build" a lot less useful. 3rd solution : A bit of the 2nd solutions problems adding that Jenkins will have a lot of builds, most of them irrelevant. What are your experiences on these problems? Thanks


title: What is a Munger

text: I am reading the source code of ObjectListView and there is a Munger class. What is Munger? Does Munger mean anything general in programming jargon? Afaik, the Munger in the source code wraps the methods to do map string to object properties through Reflection (C#). Thanks.


title: Why did Git get so much hype? ...while others don't?

text: In the recent years, the hype around Git raised greatly. Everybody knows about Git, nobody knows about alternatives. Other ones like Mercurial seem to be unnoticed. Both have been released in 2005, and provide similar functionalities. Moreover, Mercurial is generally considered to be easier to use, more intuitive and had for a long time better UIs. Therefore, it could be assumed that this would be a popular alternative, especially for those new to distributed version-control. Yet, it seems unknown to most people, unlike Git which succeeded pretty well. The point of this post is to try to understand this phenomenon better. How comes Git gets all part of the cake? Did they somehow use better marketing? Is it because its community is more ...ahem ..."verbose"? Is it because of the "Linus" name? Is it because of its geeky image? What's your opinion?


title: How to secure a Django application's source code?

text: I have developed a Django application for a company. Now I am about to ship it to my customer. After reading through online articles and books, I understood that securing the source code of any web application is a challenge. Is there anything that I can think to secure my Django applications's source code? This will be my last chance to try. My customer has servers that runs on Windows and Linux. Please help. Efforts made till date:   I tried different techniques like variable mapping in the code, url designs and even folder protection in the server. Now the latest attempt is that I created a VM of my application with username and password being private. This VM will be maintained by me. This approach has its own pros and cons. Any suggestions? Saas is not a solution to my problem as my application should be deployed at the customer's server and served through intranet.


title: Securing PHP source code from illegal copy

text: my IT boss asks what is the best way to secure the PHP source code against illegal copy of the code once it is deployed to clients. Is there a PHP compiler that will make the final codes unreadable? By the way, i work for a software development company using PHP.


Is the singleton pattern prone to thread safety problems? If so, what are the best methods to work around them?


title: Career change: from programming into more human-oriented area

text: I have been a software developer for approximately 9 years, starting with part-time work during my graduation year at uni. During these years I worked for number of companies, sometimes changing places twice or three times a year. They say it takes 10 years to reach 'expert' level, and while I don't think I am an expert by any measure and I have certainly met lots of people who are more knowledgeable, smarter and more focused than I am, I think I can safely say that I had my fair share of the whole programming trade and would like to move on to something else. I still enjoy programming, discovering new techniques and learning new technologies, although it got kind of repetitive - I can already see patterns in this process. It was fun to crack open things like say python, node.js, HTML5 etc. but after some time it lost its appeal. Psychology and behaviour was always something I was interested in, especially the practical, applicable bits of it. Recently I've been to some communication skills training and I realised that I have been missing out on the great deal of fun stuff - how people work and communicate, especially in subconscious, non-verbal area. Currently I am thinking of making a career change - ideally to move somewhere my technical skill would still be beneficial in some shape or form, or at least could serve as a bridge while I am transitioning there, you know, the whole gradual, bit-by-bit approach versus swim-or-drown one. I would like to hear your thoughts on this matter and to learn from you what are the possible transitions I can take.


title: Where to put custom validation while using Entity Framework

text: I am using MVC3 and Enitty Framework 4 with the Database first approach. It created the context template with its own validation for the fields based on the database. My question is where should I put the other validation based on the buisness logic. Should I put it in the Context.tt file, should it go in the controller or should it go in a seperate model?


title: Best way to throw exception and avoid code duplication

text: I am currently writing code and want to make sure all the params that get passed to a function/method are valid. Since I am writing in PHP I don't have access to all the facilities of other languages like C, C++ or Java to check for parameters values and types               public function inscriptionExists($sectionId, $userId) // PHP      vs.               public boolean inscriptionExists(int sectionId, int userId) // Java      So I have to rely on exceptions if I want to make sure that my params are both integers. Since I have a lot of places where I need to check for param validity, what would be the best way to create a validation/exception machine and avoid code duplication? I was thinking on a static factory (since I don't want to pass it to all of my classes) with a signature like:               public static function factory ($value, $valueType, $exceptionType = 'InvalidArgumentException');      Which would then call the right sub process to validate based on the type. Am I on the right way, or am I going completely off the road and overthinking my problem?


title: What to do about team member who threatens to leave all the time and is difficult to work with?

text: I work in a small development group with 3 developers. We are loosely managed and have no structure to the team. There is no designated team leader and the manager is fairly hands off. The Senior developer has been with the company for 4 years, in that time he has had a huge hand in setting up systems and keeping them running. He is not a very good developer but is a great cowboy coder and understands the network in a way I never could. He has taken the role of "lead developer" and "systems architect" because he has seniority and feels he is better at his job than the rest of us. My problem is that he threatens to quit all the time. Yesterday he informed me that in 6 weeks he will move up another level in the 401k vesting program and is planning to leave after that. When I asked him why, he said that it is because our manager (a man) and the team (the team being me) are “demasculating” him. He feels that he "deserves" to have been made the development manager based on his seniority. He doesn't like me because I keep pushing for things like bug/issue tracking software and because I am good at my job. Last time he threatened to quit I took him seriously and started to plan my work around him leaving. Then he changed his mind and told me that the work I was doing was his responsibility. He lost his temper with me and tensions ran really high for a while. Here are some of the different ways I have approached the situation:   1. Just do what he asks: This lowers tensions but then nothing gets done and the users get upset.   2. Take control and get stuff done: This keeps the users happy but then he gets angry at me and shuts down, he won't talk to me or work with me to get the things done that only he knows about. He won't give me access to the systems I need to get into to do it myself.   3. Work more closely with higher management: He has no respect for higher management and they don't want him to leave the company so they coddle him. One option I haven’t moved forward with yet is to leave the company: I haven't been there a year yet and don't like the idea of leaving. Overall the job meets most of my requirements in a position. Ideas? Suggestions? Conversations? Options I haven’t considered? **Update 5/11/2012:**   I finally decided to leave. It was a good decision. Between the original post and now he got better but still was not what I consider to be a good developer, much less good management material. I respect him for his knowledge but am glad I don't need to work with him any more.


title: How to organize my site's file system properly?

text: Doing some reading on Stack Overflow, I've found a lot of information suggesting that proper organization of a file system is crucial to a well- written web app. One of the key pieces of evidence is high-frequency references to "separation of concerns" in questions related to keeping programs organized. Now, I've found some information on organizing file systems (Filesystem Hierarchy Standard) from 2004. It raises only two concerns: first, the standard's a bit dated, so I believe it may be possible to do better given the changes in technology over the past 8 years; second, and most important, my application is very small compared to an entire Linux distro. I think that the file system should be organized very differently because of that. Here's what I'm looking at, currently:               /backup     /databases     /scripts     /www        /www/dev         /www/dev/login.php         /www/dev/router.php         /www/dev/admin pages (php files)         /www/dev/sites           /www/dev/sites/content types (php/html files)           /www/dev/sites/static pages (php/html files)           /www/dev/sites/modules             /www/dev/sites/modules/module-specific-media           /www/dev/sites/includes           /www/dev/sites/css           /www/dev/sites/media       /www/production         /www/production/login.php         /www/production/router.php         /www/production/admin pages (php files)         /www/production/sites            /www/production/sites/content types (php/html files; not a directory)           /www/production/sites/static pages (php/html files; not a directory)           /www/production/sites/modules             /www/production/sites/modules/module-specific-media           /www/production/sites/includes           /www/production/sites/css           /www/production/sites/media


title: How can QA prevent defects?

text: Also according to **Software Testing By Srinisvasan Desikan, Gopalaswamy Ramesh** or ISTQB text books. Quality assurance is e.g. reviewing products, inspections, walkthroughs to see if all standards are being followed. This is preventive activity. I cannot see how this can be preventive? * * * For the references: > defect prevention (Quality Assurance) **Software Testing By Srinisvasan Desikan, Gopalaswamy Ramesh** > Quality Assurance (QA) tries to go one step further. Instead of > concentrating on post- facto defect detection and correction, it focusses on > the prevention of defects from the very start. Managing Global Software Projects - Page 110 > QA deals with prevention of defects in the product being developed. Software Testing and Quality Assurance


title: Do I need to go back and learn HTML 5 and CSS 3?

text: I have been working on learning as much as I can before starting college to change my career, and I noticed on the w3schools site that there is now html and html 5, css and css 3. Do I need to go back and learn those newer languages before moving onto PHP and MySQL?


title: How do I document roles and responsiblites

text: When working on a requirements document, how do I capture system roles and responsibilities? E.g. "I'm a manager and I will only use the system to generate reports on xyz". I was looking for an example online but couldn't find one.


title: How to plan development

text: I am a self-taught 17 year old who knows Java and C# as well as I can, be learning them for over a year but I have never coded anything so therefor no experience.Me and my friend are working together on a program, I am coding the server and he is coding the client but my mind just goes blank, I have no idea where to start apart from maybe outlining some of the class structures, for example a package of packets that will be sent back and forth. How do I start to get my head around this? My mind just goes blank, I don't know what to do? I am desperate now as I want to get on in developing this but have no idea where to start, any tips will be appreciated!


title: Capturing window the GDI way, question about SaveCapturedBitmap();

text: I want to make a program that takes a screenshot of the desktop window including overlapping windows and then scans the bitmap for certain pixels at specific locations to identify. I read this is how you do it from: http://www.codeproject.com/Articles/5051/Various-methods-for-capturing-the- screen               Void CaptureScreen()     {         int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);         int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);         HWND hDesktopWnd = GetDesktopWindow();         HDC hDesktopDC = GetDC(hDesktopWnd);         HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);         HBITMAP hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC,                                  nScreenWidth, nScreenHeight);         SelectObject(hCaptureDC,hCaptureBitmap);          BitBlt(hCaptureDC,0,0,nScreenWidth,nScreenHeight,                hDesktopDC,0,0,SRCCOPY|CAPTUREBLT);          SaveCapturedBitmap(hCaptureBitmap); //Place holder - Put your code                                     //here to save the captured image to disk         ReleaseDC(hDesktopWnd,hDesktopDC);         DeleteDC(hCaptureDC);         DeleteObject(hCaptureBitmap);     }      I dont understand what it means by placeholder at SaveCapturedBitmap and I don't know what SaveCapturedBitmap does, can't find anything searching for it at msdn..


title: Need help identifying a league scheduling algorithm

text: I am trying to create a sports league scheduler. I am having trouble identifying an algorithm to help me efficiently fill in each slot. Sample data to build the schedule would be:   1. 10 teams   2. Each team plays each other 1 time (45 total games required)   3. Each team plays no more than 1 time per day   4. In my testing I am using 9 days with 5 slots per day. **Combo Table (contains 45 combos)** ID Team1ID Team2ID bitAssigned **Schedule Table (contains 45 time slots)** scheduleID homeTeamID awayTeamID GameDate GameTime Right now my existing procedures fill about 90% of the slots leaving 10% of my slots empty to a scheduling conflict based off the rules above. I loop over my schedule table in ascending date/time order. My first slot could be Saturday at 8am. I query a list of teams that haven't been scheduled yet. I then make an array of possible combinations of those teams. I then use that array to pull 1 random record from my combinations table from of combinations that haven't been scheduled yet and I place those teams on the schedule. I then set that combination as used. I repeat the loop over and over again and each time my list of available teams gets smaller and my array as a result is smaller too. I'm finding that some days go fine, and on other days my final last 2 remaining teams have already played in a previous week so they are not added to the schedule again. The only thing I havent tried yet is to "reset" the conflict days and try them over again to see if I get better placements. Does anyone have any suggestions?


title: Converting VB6 app to ... what?

text: I've been tasked with getting rid of a VB6 application. It's heavy with data input forms, tabs, modal dialogs etc. I see my options for the UI as:   1. rewrite as-is in Winforms    2. rewrite as-is in WPF    3. redesign UI completely and write in WinRT XAML    4. redesign as web app using ASP.Net MVC    5. redesign as web app using Angular All of these except Winforms will require much of a learning curve for me and my team, but I assume Wnforms is dead. What are others doing and why?