title: How well will a C++ app communicating through Apache handle traffic?

text: I'm writing an online game that has to run in a web browser and I'm worried about whether my server-side architecture will be able to handle the load. I'm designing for 1000-2000 simultaneous clients. Each client will need to query the server once every 2 seconds - so 500-1000 transactions per second is my design goal. My game server communicates with Apache via FastCGI. I'm actually running Apache on Windows for the moment. All this will run on a dedicated "dual-core" server. The game server application itself is written in C++ and the transactions are pretty simple and fairly low bandwidth (maybe 2k data per) so I'm not too worried about the game server piece. My client is written in Javascript and uses XMLHTTP to communicate with the server. So am I smoking something to think I can get 500 to 1000 transactions per second? If so, what number might I expect?


title: What is the best way to study and become involved in software engineering process work?

text: This might sound rather strange for someone who just graduated with an undergraduate degree in software engineering, but I'm extremely interested in the process and people side of software engineering. (You should see some of the looks I've gotten during interviews when asked about my professional interests and strengths, which were then followed by questions and interesting discussions on these topics which often surprise interviewers.) The people side includes customer-facing (requirements, acceptance testing) and organizational-facing (management and leadership). A look over my transcript and my answers to questions here pretty much shows this. I've had these interests well before I graduated: I took extra classes in the process-oriented track, as well as minoring in business management (focusing on organizational behavior and leadership classes) and communication (focusing on group and technical communication). A few examples of what I'm interested in:   * process models and methodologies   * process and software quality   * measurements and metrics   * project management   * organizational behavior   * organizational communication   * leadership   * software development life cycle   * software engineering as a profession I also consider myself well-read on these topics. I've read several of the major books - McConnell's Rapid Development, Software Project Survival Guide, Software Estimation, Professional Software Development, Boehm's Software Engineering Economics, Kan's Metrics and Models in Software Quality Engineering, Brooks's Mythical Man Month, DeMarco & Lister's Peopleware. I'm also well-read on the entire SDLC, from Weigers' Software Requirements through McConnell's Code Complete and have practical experience in design, construction, and maintenance. Don't get me wrong - I think the technical side is fun. I'm into architecture, design, and programming, but I'm more interested in working with the people- oriented side of software development. However, there aren't that many opportunities as an entry-level software engineer (even with 2 years of co-op and summer employment experience in the field). Now, I'm not really sure where I should go next. I currently have a very nice job in the sector that I've always wanted to be in, doing development work. This includes both continuing to develop existing software as well as some new software development coming down the pipeline in the near future. I'm also planning on sitting for the IEEE Certified Software Development Professional in about 2 years and perhaps self-studying for the PMI's Certified Associate in Project Management before I qualify for the Project Management Professional. My personal question is: how "on track" am I? However, I also have much more widely pertinent questions that would apply to any early-career software engineers who want to go into project management/process management: * * *   * Until the opportunities to become a leader present themselves, what can an entry-level/early professional software engineer do at work? Is there anything in particular that can be done, other than seek out and/or wait for opportunities to present themselves?   * What kinds of material can be self-studied, especially in terms of these topics or related topics that would help prepare for when one enters these positions?   * In terms of continuing education, what kinds of graduate programs would focus on these topics? Not necessarily specific universities, but would this typically be engineering programs, business programs, or some kind of multidisciplinary programs? How would one go about finding universities with programs that offer this kind of education?   * Where is the current state-of-the-art in this research? This is both in terms of publications and where key players are located (universities, organizations, conferences, and so on)?


title: How can a Silverlight app talk to another app on a Mac?

text: Is there any way that a Silverlight out-of-browser app can communicate with another app (for example an Objective-C app) installed on a Mac? Any help or suggestion will be highly appreciated.


title: Is distributing patches in compliance with the GPL?

text: I'm designing a distro and some of the software packages included are maintained in such a way that my source repository doesn't actually include the source code, but they are included as an `svn:externals` property or a list of read-only repository URLs and are checked into the source tree before building. Sometimes, the software requires a patch or two in order to build or work properly. These patches _are_ included in the source tree and are automatically applied but not included in the end result. The repository is public and anyone can get the patches, which are maintained regularly. My question is, is any of this setup violating the GPL? I really want to distribute under the GPL or compatible license, but I'm not really well-versed in legalese. Would I have to host repository snapshots once I publish in order to be in full compliance, or could I just host the patches?


title: How do you support your code post employment end?

text: What is the process for leaving a company (or even a group/division) in terms of code support? Is it best to handle all questions? Do you give the remaining developers access to yourself as a future resource? If so, is there a way to not give full access? I've experienced first hand where answers about the general software arthitecture from the initial developer would be invaluable. I understand that if serious assistance is needed, than it becomes a typical case of employment negotiation as a support contract. However, should serious assistance be required, what steps can you make to ease that process of contacting you? I was thinking of doing something like making a (YOUR_NAME)_codesupport @ (YOUR_FAVORITE_EMAIL_CLIENT).com address. **My Situation Specifics:** I'm a co-op student, and as such bounce around companies on 4-month stints. This means introducing myself to a lot of new code bases, as well as leaving a fair share of orphaned code behind when I leave a company. I feel bad if I leave junk code around.


title: Are There Realistic/Useful Solutions for Source Control for Ladder Logic Programs

text: Version control for ladder logic (LL) programs for programmable logic controllers (PLCs) seems to be virtually non-existent. It may be because LL is a visual language and tends to be stored in binary files, or it may be because source code control hasn't "caught on" in process control engineering circles - or perhaps my Google-Fu is weak tonight. Do you know of any realistic and useful solutions for version control for such systems? Definitions:   * realistic = changes to the programs are tracked by user and subject to reversion and merges   * useful = the system integrates with visual LL designers, is not limited to LL from a single PLC manufacturer, and does not cost a ridiculous amount of money? Note: I have heard of people using SVN or Mercurial et al to track the binary files, but I don't think the diff/merge capabilities would display readable differences. ADDENDUM: At first we only had to support Allen-Bradley PLCs. Now we also have Siemens and MicroLogix PLCs. Still searching for a viable solution...


title: backup visual studio folder and sql database

text: I like to backup things every night or say every week. I'm sure there's a more efficient way than emailing the solution folder and database files to myself! I don't have team foundation or any commercial products like that. I'm looking for a freeware.


title: Java and .NET: Why different sorting algorithms are used by default?

text: Just wondering why `Java` and `.NET Framework` uses different sorting algorithm by default. **In Java** `Array.Sort()` uses Merge Sort algorithm by default and as Wikipedia.com says: > In Java, the Arrays.sort() methods use merge sort or a tuned quicksort > depending on the datatypes and for implementation efficiency switch to > insertion sort when fewer than seven array elements are being sorted **In .NET Framework** `Array.Sort/List.Sort()` uses Quick Sort as default sorting algorithm (MSDN): > List.Sort() uses Array.Sort, which uses the QuickSort algorithm. This > implementation performs an unstable sort; that is, if two elements are > equal, their order might not be preserved. In contrast, a stable sort > preserves the order of elements that are equal. By looking at the great "Comparison of algorithms" table we can see that both algorithms has pretty different behaviour from Worst Case and Memory Usage perspectives: ![enter image description here](http://i.stack.imgur.com/fslGh.png) Both `Java` and `.NET` are great Frameworks for Enterprise Solutions development, both has platforms for embedded development. So why they are using different sorting algorithm by default, any thoughts?


As the question says on the tin: Can I integrate software under Creative Common for commercial gain? I want to use Creative Common software (e.g., http://thrivingkings.com/apprise/) for some big clients.


title: Getting Involved?

text: I've been sitting at my computer for about an hour and a half, browsing around and trying to find something worthwhile to do that I'd enjoy. The fact that I'm here shows you that I didn't come up with anything. Anyways, I was wondering about good ways to get involved with open source projects and/or contributing to stuff, without being an expert in whichever language(s) being used, if that's even possible. If it helps, I'm looking for web-based projects especially, so...yeah. Any suggestions would be appreciated!


title: Open Source - First Project

text: I am a fairly novice programmer - 6 months into an internship. I have decided to sign up to an Open Source project to learn new skills, and I have been accepted onto one. It seems the project is quite early in its life. They accept beginner programmers and I have explained that I am one. Obviously as this is my first contribution, I don't want to annoy anybody ont he project. As such, what things do I need to be aware of? Any specific etiquette I should be aware of? Will I need any specific software? I have VS2010 which is okay for C#, but what about source control? Is that managed through the Codeplex site? Thanks.


title: Unit Tests for Database Abstraction Layer

text: I previously asked this question about creating an algorithm for joining records from multiple databases, and since then, I have built a rudimentary version of it (which doesn't allow for inter database table associations to keep it simple for the moment), and now I am trying to test it. So far, I have tested doing joins, custom columns, where and having clauses, order by's, and limits, and they seem to all work perfectly. But, most of my applications that do database queries are quite simple, with just a few joins, a couple of custom columns, and a few other bits and pieces of information, so I was wondering if there was a nice series of really complex queries i could pass through it to ensure that it can really do everything that would be needed by 99% of applications? I know its a bit broad, but even just a handful of complicated queries would be fantastic to test it out.


title: Source control system for binary files

text: At work we have a legacy system written in Visual FoxPRO. Everything in foxpro is a table, even forms, so basically if you open a form file with a text editor you don't learn much. Does anyone know about a tool for source control, that support merging and managing binary files? For now I'm converting what I can convert to text, use a text tool like to merge changes, and replace them manually, to get the team work in one version, then upload the stuff to a TFS server. I know it is not genius... please advise


title: How are Scala Traits implemented in the JVM?

text: I have been reading about traits in Scala. They are pretty amazing. I am curious how they extend a class without actually resulting in multiple inheritance. I know that the JVM doesn't support multiple inheritance, so I am wondering how these extensions work. Is the language just providing syntactic sugar for composition? Or is the code within a trait duplicated in each class that uses it?


title: Preferring Database Normalization vs. Schema Transparency?

text: A new requirement has surfaced on an old codebase, that basically enables direct (internal) communication between two formerly not-directly related classes of users (stored in different tables with completely different schema and, sadly, the code is barely OO-aware, much less designed, so there's no parent class). Since we're out to hang a bag on this old setup that never considered this functionality, there's no guarantee that there are no PK collisions -- given the dataset in use, it's practically guaranteed that there ARE. So, the solution seems obvious: ~~kill it with fire and rewrite the whole mess~~ A mapping table. I've gotten two directions for the possible ways to implement the map, but I'm not a DBA, so I'm uncertain if there are any pros and cons I've missed. For the sake of clarifying the abstraction, consider three groups of disparate user data: Professors, Administration, Students (No, this isn't a homework assignment. Promise!) **Mapping 1** (professor_id, admin_id, and student_id are foreign keys to their respective tables)               | mailing_id (KEY) | professor_id | admin_id | student_id |      -------------------------------------------------------     | 1001             |     NULL     |    87    |  NULL      |     | 1002             |     123      |   NULL   |  NULL      |     | 1003             |     NULL     |   NULL   |  123       |      The +/- to this approach seem pretty heavy on the cons:   * Two "wasted" fields per row   * Violates 2NF   * Vulnerable to insert/update anomalies (a row with only 0-1 field set NULL, e.g.)  The pros are not without their own merits, though:   * The mapping can be accomplished with a single lookup   * Easily determine the "source" data for a given user from the mailing_id Truth be told, in my gut, I don't like this idea at all. **Mapping 2** (assume MSG_* are defined constants, enum types, or another suitable identifier)               | mailing_id (KEY)  | user_type (UNIQUE1) | internal_id (UNIQUE2)|      ------------------------------------------------------------------     | 1001              | MSG_ADMIN          | 87                    |     | 1002              | MSG_PROF           | 123                   |     | 1003              | MSG_STUDENT        | 123                   |      With this setup, and a unique composite index of {user_type, internal_id} things become much cleaner, 3NF is maintained, and the application code doesn't have to check for I/U anomalies. On the downside, there's a bit of a loss of transparency in determining the user source tables that has to be handled outside of the DB, basically amounting to an application-level mapping of user_type values to tables. Right now, I'm (rather strongly) leaning toward this 2nd mapping, since the downside is rather minor. **BUT** I'm painfully aware of my own limitations, and am sure I've probably missed advantages or stumbling blocks in both directions, so I turn to wiser minds than mine.


title: Adapting to a team environment after developing alone for years

text: I have almost 5 years of experience as a web developer, and feel that I should be mid-level by now, but when I walk the walk I think I'm still pretty "junior" at it. Here's what I think is the problem: For most of my career, I seldom had any real guidance by a more senior developer and zero experience with developer teams, so I sort of had to hack my way through a lot of solutions, and do everything cut-and-dried. In practice, there was no time to waste as the only guy responsible for writing or maintaining the code. Because of this, I have no formal knowledge of the actual software development _process_ and eventually realized that coding is only a small part of the process. I would greatly enjoy working with a developer team with solid experience, but I am afraid it would be a very bumpy ride trying to adjust with the knowledge base that is required for development processes. As a programmer who has flied solo most of his career, what can I do to prepare to "settle in" a job working with a larger team (at least 5) of seasoned pros? Edit: To that end I haven't passed a lot of the technical tests given out by the "big shot" companies that thrive on their software and developers. By big I don't mean like Google, but reasonably successful in the geographic area.


title: How to deal with queries that do not return full entities in Domain Driven Design?

text: In my application, I have a listing of information that is deducted from a query that combines information from several entities. In itself, a very common situation. Now, the corresponding repository method should return a list that contains items of an appropriate type. Clearly, choosing an entity is not appropriate because the information we're dealing with spans across multiple entities. I guess the same applies when querying partial entities. Creating a new entity doesn't make sense either because it would only muddle the model. I was thinking in the direction of something like creating a DTO in the application layer because the particular query really is there to satisfy an application requirement and not a business requirement. This essentially leads to introducing the notion of application specific repositories and a dependency on the application layer from those specific repositories. Somehow this doesn't feel right. Is there a more appropriate approach/pattern I could use here?


title: Guess if a time is AM or PM

text: I'm currently in the process of writing a human date parser. By human date, I mean it should be able to interpret strings as "tomorrow at 2" and return a valid date depending on the current time. The issue I'm facing is the automatic detection of missing AM/PM token. For example, if I receive an email that says "Lets meet tomorrow at 2", I know that 2 is likely to be, in fact, 2 PM. On the other hand, if the email said "Lets meet tomorrow at 11", 11 is more likely to be 11AM. I guess most of the time, a simple comparison should do the trick. If the number is bigger than a certain limit _n_ , we can suppose that the time is AM. If the number is smaller, then it is probably PM. In the sample above, 2 was more likely to be PM, and 11 was AM. I know that a common work day is about 9AM-6PM, so numbers lower than 6 or bigger or greater than 9 are fine. We can easily guess for those. But what do I do with 7 and 8? So the exact question I have is, where do I put this exact limit? When numbers approach 7~8, the limit becomes more ambiguous. I tried to search for previous documentation on this problem but couldn't find any. Is there any kind of convention about this? Also, in my opinion, the locale and/or timezone could influence this limit. By the way, I'm not interested by non-definitive answers such as "In my opinion, 7 is afternoon" or "For me, 8 is morning". I'm really interested in documentation that could help me draw a definitive line. Hope the description of the problem is understandable enough.


title: Is it important/essential to learn software development methodologies for beginners?

text: I'm a student and I've been programming for not very long. Particularly, I'm learning CodeIgniter framework - The book I'm reading is "Professional CodeIgniter". In the book, the author mentioned Agile Methodologies ( and I find it somewhat little bit difficult to understand ). I want to know if it is essential to learn the methodology first before starting to produce software or should I learn coding to be good at it first?


title: What are some good interview questions for nontechnical recruiters to ask?

text: I've been given the opportunity to provide a question bank for nontechnical recruiters to ask candidates. However, all of my favorite interview questions require somebody who knows the subject matter to properly evaluate the answer (eg. how would you design X, How do you feel about Y). I'll probably need to have a combination C#/.Net questions and more general programming questions, and the tricky part is they all need to have answers that the recruiters can confirm without understanding them. Any thoughts?


title: Is there a scalable multi-site strategy with codeigniter?

text: I've been looking for a efficient and secure way of enabling multi-site capabilities to codeigniter for a while. These two(one & two) articles I found pretty interesting, but they don't seem to offer a scalable way of doing it. Of the two, John Dennis Pedrie's(link two) method seemed to be more thought out for our purposes. However, say you have 100, 500, or 1000 separate sites, is this method still the best to go? Ie. would having 500 separate db config files in a folder and updating them with php be the best way to go? Another method I can see being useful is a database of config options. Update the DB and you could have another site come online. However that would require storing all the database usernames and passwords in cleartext. Can't see that going over well. Any answers, advice, tips, or interesting thoughts?


title: Understand scripting language

text: Quoted from Wikipedia: > A scripting language, script language or extension language is a programming > language that **allows control of one or more applications** and **makes the > compiler of the language part of the language runtime** , and as a result, > **enables code to be generated dynamically**. "Scripts" are distinct from > the core code of the application, as they are usually written in a different > language and are often created or at least modified by the end-user. Scripts > are often interpreted from source code or bytecode, whereas the application > is typically first compiled to native machine code.   1. I was wondering what "enables code to be generated dynamically" means? Isn't code in a scripting language written before it gets run, so how is it generated dynamically?   2. By definition, is a scripting language always an interpreted language? Conversely, is an interpreted language always a scripting language? They seem to be very close related, or even the same thing.   3. How is a language non-scripting? Thanks and regards!


title: Model independency in MVC and most efficient way to do method calls

text: **TLDR:** Are models supposed to be application-dependant and totally worthless when starting a new application, or are you supposed to design models independently so that they act as stand-alone classes/libraries? (This would make little sense with a framework such as CodeIgniter where you extend the `CI_Model` which obviously won't be there in your Kohana project.) I've also read several similar questions to some of my points here, but this is the main point which I have not found an answer to. I've been using CodeIgniter for quite a while which introduced me to the MVC pattern. Even though it took a while to get into it has paid off the more I've read, reflected and inspired myself about it, however there is something that has always been constantly annoying me; how to properly put together a valid, efficient and working composition of objects. Considering the three different workareas of the MVC structure I use (controller, model and library - yes, I said library, for independent class inclusion), I've had a hard time deciding whether the model should act as an independent class itself or only act as a structure to the application as the so-called 'black box', 'business model' or 'fat model'. I do keep my controllers 'skinny' and try to do so because all documentation I've read have tried to point that out, but since the controller is application-specific and not independent (in such a way that I could just take it from the application and apply it to another totally different application), I've come in confusion if the model is supposed to act in a similar fashion, simply being a pair of organized 'fat' classes being tied to the main application, losing all their worth if moved to a totally new project. And exactly this is the core of my problem and I really need to get a crystal- clear definition about this. To help you further understand what I mean I can give a few examples: I'm making an application with PHP at the moment where I have a model called `users.php`. Within this class I have methods working against the 'users' table, such as this:               /**          * Runs the login credentials against the database          * @param string - username          * @param string - password          * @return user_id / false          * */         public function verifyLogin($username, $password) {                  $password = $this->_hashPassword($password);                  $this->db->where('username', $username);             $this->db->where('password', $password);             $this->db->where('activated', 1);             $this->db->where('deleted', 0);                  $query = $this->db->get(DB_PREFIX.'users');                  if ($query->num_rows() > 0) {                 $r = $query->result_array();                 return $r[0]['id']; // User ID             }              }      The model is loaded into the framework and I call this method from the controller like this:               $this->users->verifyLogin($_POST['login_username'], $_POST['login_password']);      The way I used to call it before was `$this->users->verifyLogin();`, letting the model simply take the `$_POST` variables and figuring it all out by itself. I just changed this as I would assume that controlling all input and output should go through the controller, virtually leaving the model 'actually fully encapsulated' even to me as the author of the code. This shows the connection between my Controller and my Model, but what if I decided to use an independent library, say a Validation class I had made? Where would I implement this stand-alone class? Let's pretend this is a snippet of my application where I use my poorly designed validation class to give me an exception:               require_once('validator-class.php');          $val = new Validator($_POST['login_username']);          try {     $val->max_length(16)         ->min_length(4)         ->alpha_numeric();     }      Would I put this code into the controller or the model for best effect? If the model would be application-dependant, it would make most sense to delegate/call the methods of the library class from within the model and then very easily just call the model in a more simplified fashion such as a `save()` method where everything would be taken care of behind the scenes. I've come to wonder if the controller is supposed to be used as a 'main area' for connecting the dots, being the place where I would call the methods of every class, delegate them to the model etc. while keeping the model 100 % outside-class-clean, only relying on itself solely and surely. But then again, if the model is supposed to be application-dependant, this would make little sense as I would not take the model with me to a new project and should instead just do all the calling and messy procedures within the encapsulated class. I must apologize for the long explanation, but I struggle with even using the MVC pattern with this question in mind to the extent I'm seriously considering just letting go and moving back to the hard, pure PHP. Some help would be very appreciated. Also, a few tips on documenting class methods would be very welcome as a bonus. Thanks a great deal!


title: Industry jobs in artificial intelligence

text: As a relatively new computer science student, I am trying to find my niche within this broader field. My main goal is not academia but, well, a job. As such, I want to choose a specialization or two that will provide two benefits: 1\. Interests me. I will find the work to be engaging and enjoyable. 2\. I can actually get a job doing it. My more rational brain is encouraging me to do something like database work or web development, seeing as there will likely be an ongoing need for that type of work. On the other hand, I am finding myself attracted to things like artificial intelligence and machine learning, as they both seem really fascinating. I could see myself doing some really exciting things in that area. However, I often get the impression that it's more of an academic thing than something with actual industry demand. (Though that's just my immediate perception.) Do you think an AI specialization is likely to open up sufficient job prospects. Although it seems interesting, I'm the kinda person who is fine with doing work that isn't necessarily that interesting, and I'm more concerned with job availability and security, at this point in time. Your thoughts are appreciated...thank you!


title: Distributed SCRUM team issues: The work environment

text: One interesting issue appeared for me today. In a distributed SCRUM team when do you start enforcing an unitary work environment in terms of code format, IDE plugins (checkstyle & co), VCS, CI? The team is in an exploratory phase and thegoal is not production quality code but rather proof-of-concept. Isn't it an overhead to enforce some common coding rules "a priori" - before the team members decide which are really relevant for their future work? Using this kind of tools is for sure a huge benefit because they act as an heuristic to minimize the technical debt but enforcing rules as "no trailng spaces" that really break the Jenkins build seems for me an overkill for a phase that should be focused rather on ice-beaking than on creating production code. Mention 1: the prototypes create will be thrown away Mention 2: although I wish that everything should be done right from the beginning - I m totally aware that it is not 100% possible.


title: Where's a good place to learn how to develop a schedule/appointment system in C#?

text: Not a job/task schedule, but actual appointment system people can use to create recurring events. It should support many recurrence patterns such as 1st Monday of each month, every Tues/Thurs, a specific date, etc. Everywhere I search I find many example of C# job schedulers but not any appointment systems. I've been programming as a hobby for quite some time but have never tackled an appointment system before (I have attempted a couple times, but gave up and moved on to other things). What are some good websites to find tutorials covering this? Or, are there any good books on the subject?


title: Finding "spare time" in a day from within a list of events

text: I have a list of events which is always sorted chronologically. The start time is always followed by the end time. Times are strings formatted as 'HHmmss'.               // list of events          var events = [         '010000',  // start         '013000',  // end...         '053000',         '060000',         '161500',         '184500']          // desired output          var spares = [         '000000',  // start         '010000',  // end...         '013000',         '053000',         '060000',         '161500',         '184500',         '235959']      How can I programmatically create a new list of "spare time" from `000000` to `235959`? PS I'm trying to do this in Javascript, but any conceptual answer or pseudo code would be helpful too.


title: Programming Language Parser (in Java) - What would be a better design alternative for a special case?

text: ### Background I'm currently designing my own programming language as a research project. I have most of the grammar done and written down as context-free grammar, and it should be working as is. - Now I'm working on the actual compiler that should translate the language into `x86 binary assembly code`, more specifically, I am working on the `parser` (the front end). The language's syntax is, for the most part, very similar to Java/C/C++. The parser, which constructs an intermediate representation out of source code, works as follows: The grammar is built as a big tree in which the actual source code only determines the leaves; Each syntactic variable (or nonterminal) has it's own class, and each of these classes has a `static get(byte[] source, int offset)` method which returns a new leaf (node), or `null` if the source code syntax does not fit this nonterminal structure. I am using a variation of `predictive parsing`, by the way. For the nonterminal `DataType`, I have chosen the following grammatical structure:               DataType:         PrimitiveDataType      |  ArrayDataType      |  ComplexDataType          ArrayDataType:         DataType []      Did I mention this language is object-oriented? So the problem here is that when `DataType`'s `get` method is called, it first checks whether the following is a primitive data type, `PrimitiveDataType`'s `get` method is called. Assuming we have an array, this would return `null`, so it continues on to check whether it's an `ArrayDataType`, by calling it's `get` method. ### Problem Arrays may be created of any data type, including arrays themselves (which would look like `Type[][]`). So what `ArrayDataType`'s `get` method would do is again call `DataType`'s `get` method to figure out what type the array is of. Unfortunately, this is where my parser implementation would fail because this behavior results in a loop! ### Question Would there be any _good/better_ design alternatives to this?


title: C# Coding Standard - Position of Attribute in relation to Target

text: I had thought that this was one of the few _solved problems_ in C# coding standards / style; `Attributes` always appear on the line above the thing to which they are applied _a la_               [SomeClassAttribute]     class SomeClass     {        [SomeFieldAttribute]        bool someField;             [SomeEnumAttribute]        SomeEnum        {           SomeValue        }             [SomeMethodAttribute]        void SomeMethod()         {         }     }      But recently I've started to see `Attributes` in-line with the thing to which they are applied:               [SomeClassAttribute] class SomeClass     {        [SomeFieldAttribute] bool someField;             [SomeEnumAttribute] SomeEnum        {           SomeValue        }             [SomeMethodAttribute] void SomeMethod()         {         }     }      For example on the Microsoft website and in the FileHelpers open source project. Is this just _laziness_ on the part of the author of example code, or something that people actually use on a day to day basis, and if so why?


title: Ideal way to define a table or grid in XML?

text:
## HTML

         Month	         Savings

         January	         $100

         February	         $80

      ## XAML               <Grid>         <Grid.RowDefinitions>             <RowDefinition Height="Auto" />             <RowDefinition Height="Auto" />             <RowDefinition Height="*" />             <RowDefinition Height="28" />         </Grid.RowDefinitions>         <Grid.ColumnDefinitions>             <ColumnDefinition Width="Auto" />             <ColumnDefinition Width="200" />         </Grid.ColumnDefinitions>                                    <TextBox Grid.Column="1" Grid.Row="0" Margin="3" />         <TextBox Grid.Column="1" Grid.Row="1" Margin="3" />         <TextBox Grid.Column="1" Grid.Row="2" Margin="3" />         <Button Grid.Column="1" Grid.Row="3" HorizontalAlignment="Right"                  MinWidth="80" Margin="3" Content="Send"  />     </Grid>      In HTML, there's some ambiguity on how you set the width of a column. You have to specify it on the th/td, but there are multiple of those within the same column. WPF solves this problem by introducing "definitions", but then you have to explicitly specify which cell you want to insert each element in to, adding a lot of extra markup. Also, what happens if you miss a cell, or try to put two elements into the same cell? What about something like this?               <grid>         <coldefs>             <coldef width="150" />             <coldef width="100" />         </coldefs>         <rowdefs>             <rowdef height="50" />             <remainingrowdef height="auto" />         </rowdef>              <cell>Month</cell>         <cell>Savings</cell>         <cell>January</cell>         <cell>$100</cell>         <cell>February</cell>         <cell>$80</cell>     </grid>      Where the cells just fill left to right, top to bottom? Pros/cons? Other options? * * * Better yet, you can specify the fill order too! Just add an extra argument `<grid fill_order="left-right,top-bottom">`


title: Convince someone that an app cannot be done

text: I am profoundly disturbed by a request that asks me to develop an iPad app to measure the actual size of an object using camera. It is simply not practical. Translating 2D object into 3D is never easy. I either need extra hardware, or have to make a lot of assumptions (which will almost never hold true). Regardless I will need time. However, the person who requested me to develop the app is adamant of his vision. And he tries to show that he is right by listing a number of existing apps that do similar jobs. He does not realize that all the apps he refers to has a rating lower than three stars, which means they probably do not do their job. How can I convince this person that such an app simply cannot be done in a practical, single developer fashion? Is there a PhD thesis I can use as my defense?


title: Should I use abstract or virtual methods?

text: If we assume that it is not desirable for the base class to be a pure interface class, and using the 2 examples from below, which is a better approach, using the abstract or virtual method class definition?   * The advantage of "abstract" version is that it is probably looks cleaner and forces the derived class to give a hopefully meaningful implementation.   * The advantage of the "virtual" version is that it can be easily pulled in by other modules and used for testing without adding a bunch of underlying framework like the abstract version requires. Abstract Version:               public abstract class AbstractVersion     {         public abstract ReturnType Method1();                 public abstract ReturnType Method2();                  .                  .         public abstract ReturnType MethodN();              //////////////////////////////////////////////         // Other class implementation stuff is here         //////////////////////////////////////////////     }      Virtual Version:               public class VirtualVersion     {         public virtual ReturnType Method1()         {             return ReturnType.NotImplemented;         }              public virtual ReturnType Method2()         {             return ReturnType.NotImplemented;         }                  .                  .         public virtual ReturnType MethodN()         {             return ReturnType.NotImplemented;         }              //////////////////////////////////////////////         // Other class implementation stuff is here         //////////////////////////////////////////////     }


title: Why not write all tests at once when doing TDD?

text: The Red - Green - Refactor cycle for TDD is well established and accepted. We write **one** failing unit test and make it pass as simply as possible. What are the benefits to this approach over writing **many** failing unit tests for a class and make them all pass in one go. The test suite still protects you against writing incorrect code or making mistakes in the refactoring stage, so what's the harm? Sometimes it's easier to write all the tests for a class (or module) first as a form of 'brain dump' to quickly write down all the expected behavior in one go.


title: Using Cucumber with Page objects

text: We are using Cucumber in our application, but previously used Selenium. Cucumber is far better than Selenium, but it may seems to be complicated since has to write gherkin, step definitions may be page objects. We are using Celerity with Jruby. The flow is: 'gherkin' calls 'Step definition' calls 'Page objects'. On one hand, every QA tester writing Cucumber tests will have to be familiar with Ruby in order to use page objects, but on the other hand we can avoid code duplication and repeatedly broken tests. What are the pros and cons of using page objects with Cucumber? Should we stop worrying about duplicate code in tests and stick with using step definitions instead of page objects?


title: Can I create a desktop Python GUI application and run it as a web app?

text: I'm working on a project where multiple (several hundred perhaps) users will need to run an application remotely. We thought that running a web app would be the best course of action to go. (Note: when I say web app I mean a program where a user can type in a URL that will then allow the user to run the application we're working on remotely without any installations or limited installations to the browser they're using) My problem is not knowing where to start in creating a web app. The way that I see it (and correct me if I'm wrong), there are two types of web apps out there. A Rich Internet Application which: > has many of the characteristics of desktop application software, typically > delivered either by way of a site-specific browser, via a browser plug-in, > independent sandboxes, extensive use of Javascript, or virtual machines. wiki or a 'regular' web app similar to gmail. I'm very familiar with Python and desktop GUI development using wxPython. Is it possible to write a program in Python, and then run it as a webapp? If so, How?


title: Managing references in open source .NET project?

text: What is the best practice for managing references in a .NET open source project? I'm writing a small library that will use Json.NET. Should I check the Json.NET DLL straight into source control?


title: Is it common/correct using MVVM to expect multiple views and corresponding view-models for a particular model?

text: Consider a somewhat contrived model that goes something like:               class Player     {         public int Health;         public int Ammo;         public Weapon CurrentWeapon;         public PhysicalState State         {             get             {                 if (this.speed <= 0.1)                     return PhysicalSpeed.Standing;                 /* and so-on for Strafe_left, Running, etc. */             }         }     }      In the expected visual for such a game it is known that the heads-up display (HUD) will display things like Health and Ammo, whereas the avatar will show the weapon and the animation based on the physical state. So, assuming you have a HUD_View and a Player_View that draw the HUD and the player respectively, is it correct, within the confines of MVVM to have 2 view-models for the Player model, that are only ever intended to expose a subset of information in the model or is it expected that the model will be split in two as well? Is there anything that I'm missing? Can someone point me to, or provide a more concrete example of the correct solution (even if my thinking is correct, so that I might solidify my understanding here)?


title: Objective-C message passing related queries

text: I am learning objective-C after having good knowledge of C/C++. I have 2 questions:   1. Are Obj-C message passing and C++ vtable, two different ways of implementing polymorphism or Are they two very different concepts which I have misinterpreted into different implementations of same concept?   2. I read following line from this pdf http://www.gnustep.org/resources/documentation/ObjectivCBook.pdf > Polymorphism takes a pluralistic point of view and notes that several > classes can each have a method with the same name. Argument overloading > takes the point of the view of the method name and notes that it can have > different effects depending on what kind of object it applies to In essence both do what we want from them i.e. calling method according to the object. What is the difference then?


title: Should I expose IObservable<T> on my interfaces?

text: My colleague and I have dispute. We are writing a .NET application that processes massive amounts of data. It receives data elements, groups subsets of them into blocks according to some criterion and processes those blocks. Let's say we have data items of type `Foo` arriving some source (from the network, for example) one by one. We wish to gather **subsets** of related objects of type `Foo`, construct an object of type `Bar` from each such subset and process objects of type `Bar`. One of us suggested the following design. Its main theme is exposing IObservable objects directly from the interfaces of our components.               // ********* Interfaces **********     interface IFooSource     {         // this is the event-stream of objects of type Foo         IObservable<Foo> FooArrivals { get; }     }          interface IBarSource     {         // this is the event-stream of objects of type Bar         IObservable<Bar> BarArrivals { get; }     }          / ********* Implementations *********     class FooSource : IFooSource     {         // Here we put logic that receives Foo objects from the network and publishes them to the FooArrivals event stream.     }          class FooSubsetsToBarConverter : IBarSource     {         IFooSource fooSource;              IObservable<Bar> BarArrivals         {             get             {                 // Do some fancy Rx operators on fooSource.FooArrivals, like Buffer, Window, Join and others and return IObservable<Bar>             }         }     }          // this class will subscribe to the bar source and do processing     class BarsProcessor     {         BarsProcessor(IBarSource barSource);         void Subscribe();      }          // ******************* Main ************************     class Program     {         public static void Main(string[] args)         {             var fooSource = FooSourceFactory.Create();             var barsProcessor = BarsProcessorFactory.Create(fooSource) // this will create FooSubsetToBarConverter and BarsProcessor                  barsProcessor.Subscribe();             fooSource.Run(); // this enters a loop of listening for Foo objects from the network and notifying about their arrival.         }     }      The other suggested another design that its main theme is using our own publisher/subscriber interfaces and using Rx inside the implementations only when needed.               //********** interfaces *********          interface IPublisher<T>     {         void Subscribe(ISubscriber<T> subscriber);     }          interface ISubscriber<T>     {         Action<T> Callback { get; }     }               //********** implementations *********          class FooSource : IPublisher<Foo>     {         public void Subscribe(ISubscriber<Foo> subscriber) { /* ...  */ }              // here we put logic that receives Foo objects from some source (the network?) publishes them to the registered subscribers     }          class FooSubsetsToBarConverter  : ISubscriber<Foo>, IPublisher<Bar>     {         void Callback(Foo foo)         {             // here we put logic that aggregates Foo objects and publishes Bars when we have received a subset of Foos that match our criteria             // maybe we use Rx here internally.         }              public void Subscribe(ISubscriber<Bar> subscriber) { /* ...  */ }     }          class BarsProcessor : ISubscriber<Bar>     {         void Callback(Bar bar)         {             // here we put code that processes Bar objects         }     }          //********** program *********     class Program     {         public static void Main(string[] args)         {             var fooSource = fooSourceFactory.Create();             var barsProcessor = barsProcessorFactory.Create(fooSource) // this will create BarsProcessor and perform all the necessary subscriptions                  fooSource.Run();  // this enters a loop of listening for Foo objects from the network and notifying about their arrival.         }     }      Which one do you think is better? Exposing IObservable and making our components create new event streams from Rx operators, or defining our own publisher/subscriber interfaces and using Rx internally if needed? Here are some things to consider about the designs:   * In the first design the consumer of our interfaces has the whole power of Rx at his/her fingertips and can perform any Rx operators. One of us claims this is an advantage and the other claims that this is a drawback.   * The second design allows us to use any publisher/subscriber architecture under the hood. The first design ties us to Rx.   * If we wish to use the power of Rx, it requires more work in the second design because we need to translate the custom publisher/subscriber implementation to Rx and back. It requires writing glue code for every class that wishes to do some event processing.


title: What is a good pattern for combined caching and reinitialization?

text: I have a situation where I have three requirements:   1. **Lazy initialization** \- don't create the collection until asked for it   2. **Caching** \- keep the collection in memory on the object   3. **Reinitialization** \- be able to reinitialize the collection when desired, instead of simply getting the existing results. This is simply an optimization inside a single class - it is not loading anything from a database and ideally I'd like just a good method design pattern for this, not a multiple-class design. Usually for lazy initialization I'd have this:               Collection getCollection() {         if (collection != null) {              // generate and set collection         }         return collection;     }      But now I'm having trouble deciding on the best way to provide for reinitialization of a fresh collection and getting that collection. A `fresh` boolean parameter would work, but adding a parameter to a getter doesn't seem to feel right (maybe that's the Java in me talking -- I could be convinced).


title: Are scheduled job servers the right choice for a time sensitive game engine?

text: I am currently architecting and designing an exciting new web application that will be entering into some areas that I have very little experience in, game development. The application is not necessarily a game, but there are some very time sensitive tasks and scheduled jobs that a server will need to run to perform game related activities (Eg. New match up starts at noon every day for a 12 day tournament, updating scoreboards at 5pm every day, etc...) In the past I have typically used cron jobs with the Quartz Scheduler running within a web application server, but I know that this isn't likely a scalable solution for the truly massive userbase that management is telling me to expect (Granted they are management and are probably highly optimistic about this) and also for how important the role of these tasks are in this web application. The other important thing I want to consider is that I want to avoid SPOF (Single Point Of Failure). If the primary job server goes down, another job server should be able to successfully run the job in its place. I suppose this can be done appropriately record locking and database transactions. My question is if scheduled jobs like CRON running on a web application server are a wise design choice given the time sensitive game tasks of this application, or is there something more appropriate for running a scalable game engine parallel to the web application servers?


title: How to maintain Motivation and enthusiasm once you have figured out the solution needed

text: I am currently undertaking a software project on my own time. When I first got the project I put in many hours working out how to do the "tricky" parts of the solution. I spent many hours googling and reading up on classes available on MSDN that I could use for the project. I was madly excited and passionate about doing this work. However once, I got a working samples of how I could get around the "tricky" parts and got to the part where all that I needed to do was "grunt" work to finish the project, I lost all interest and desire to work on he project. Suddenly instead of looking forward to sitting down and working on this project it became a chore and a major hassle to motivate myself. I am now fast approaching the deadline and I am getting the work done now, but it is under very high pressure as I have left it almost too close to the deadline! I will manage to get it done but it will involve several all- nighters. (BTW I completely despise doing these all-nighters and would love to eliminate these by maintaining my motivation and working at the project continuously.) So my questions are is this normal? Does everyone else notice such spikes and troughs in their enthusiasm for projects? Anyone more experienced have any advice on how to keep the motivation going? Or am I just not designed to work on a full project lifecycle, should i and people like me being doing an R&D type role where I can do the fun figuring out part of the projects and leave it for someone else to finish the "les interesting/mundane" coding?


title: Equivalent of #map in ruby in golang

text: I'm playing with Go and run into something I'm unable to find in Google, although there is certainly something that exists: I'm using the following struct:               type Syntax struct {       name string       extensions *regexp.Regexp     }          type Scanner struct {       classifier * bayesian.Classifier       save_file string       name_to_syntax  map[string] *Syntax       extensions_to_syntax  map[*regexp.Regexp] *Syntax     }      I'd like to perform the following using Go and I'm quoting ruby because it's how I'd do that using ruby:               test_regexpes = my_scanner.extensions_to_syntax.keys      My goal is to get an array of *regexp.Regexp . Any idea on how to do that in a simple way ? Thank you !


title: How can test users access an unpublished iOS app?

text: I am considering outsourcing the development of an iOS app to various independent developers. I will have have various testers of the app. We all work for separate companies. Some of these testers will be customers, who I would like feedback from. As there are multiple developers involved I expect there to be a new release on a daily basis. How can this be done? Would each of the testers need to buy some sort of license to avoid having to go through the app approval process? Is there any smooth way to do this so that it will not be a hassle for our friendly customers, who are willing to test our app?


title: Senior team members want to move query-relevant persistent data from DB to cache. Does this make sense?

text: I am a young engineer recently employed at a small company that sells products to the general public. We use Ruby On Rails and MySQL. Our database has a lot of customer data, but a great deal more of "static" persistent data. This data is so rarely changed that some of the more senior engineers have begun to talk about moving it to a cache data store. One of the touted benefits of this plan is that it would make deployments easier, since we would no longer have to bootstrap the database; instead, a lot of data would have permanent IDs, and we could just backup the cache and deploy the backup. My query is related to the operational aspects of running the site once the change is done, not the change itself. We have persistent data that is used for database queries in response to user activities, which is used on a day basis. Putting it in a cache would remove our abilities to run SQL queries, instead querying the cache from RoR code. I don't have enough experience to judge if this is a good plan or not, but it smells funny to me. Has anyone ever seen a situation similar to this, or have experience in this area? I'm looking for reassurance that this is not a crazy idea.


title: Handling subscriptions, balances and pricing plan changes

text: **Preamble**   My aim is to create reusable code for multiple projects (and also publish it on github) to manage subscriptions. I know about stripe and recurring billing providers, but that's not what this module is aiming for. It should just be a wrapper/helper for calculating account balance, easy notifications to renew a subscription, and handle price calculations. There are countries you can't use recurring billing because of the providers or payment possibilities having poor or no support for it or are too expensive (micropayments). And there are people that don't want to use recurring billing but pay their bill manually / avingg an invoice at the end of the year. So please don't suggest paypal recurring billing, recurly or similar services. **Situation**   Let's say you have a model that can subscribe to a subscription plan (e.g. `User`). This model has a field that stores the identifier of a subscription plan it is currently subscribed to. So, on every plan change, the change is recorded. There is a model (e.g. `SubscriptionPlanChanges`) with the following fields recording the mentioned changes:   * `subscriber` relating to the subscribing model (`User` in this case)   * `from_plan` defining the plan identifier the model had before change   * `to_plan` defining the plan identifier the model has selected now   * `created_at` is a date-time field storing the change   * `valid_until` stores the date until the actual subscription is valid    * `paid_at` is also a date-time field that defines if (and when) subscription was paid Of course, that layout is discussable. **Question of account balance**   When a User changes his/her subscription plan, I need to compare the plan fields, get the pricings, and calculate the deduction for the new plan based on the current plan's `valid_until` and its price. Say: You subscribed for a year of plan A but after 6 months, you upgrade to plan B, so you get a deduction of half the paid price for the 6 months of plan A. What I am wondering: If a user e.g. switches to the free plan, he has a credit which can be deducted if the user wants to switch again. Would you cache that value in an additional field, or calculate through all the records related to that user every time? Would you add/change something about the table layout? **Question of easy comprehensibility**   When the end of a subscription period arrives, the user gets notified and has the possiblity to renew his subscription by paying again. The easiest way would be to just update `paid_at` and `valid_until` with new subscription options. However, I am not sure if you store every data someone might need, like a payment/subscription history. Another option would be to create an additional record for this, where `from_plan` and `to_plan` are having the same identifier (thus symbolizing "no change"). But wouldn't that interfer with calculating the account balance in some way? If someone could point me into the right direction about the logics handling such subscriptions, I'd appreciate it very much. * * * **UPDATE**   Thanks for the help by now. I think my question was too vague so I'll try to be more precisely by using less abstraction. Unfortunately, I could not solve my problem yet. _Case A_   `User` can select `Subscription Plan A`. This currently stores a `SubscriptionPlanChange` to keep track of it. After e.g. 5 months, `User` upgrades his subscription to `Subscription Plan B`. So he pays the price for his new subscription, deducting the price of plan a for the unused 7 months. _Case B_   After 3 months, `User` rolls back to his `Subscription Plan A`. He does not have to pay but receives a balance for it so that, at the end of the subscription, he gets that balance deducted for his new subscription. _Case C_   `User` can select a subscription plan for a sub-service that has independent subscription plans. Same `Case A` and `Case B` can apply for that sub-service subscription. `_Case D_` User cancels one of his subscriptions. This results in a top up of his balance. My question (currently, at least) mainly depends on how to store that data properly so I can reproduce a history of subscriptions for business analysis and calculate balances, get outstanding payments based on the subscriptions etc. I am also not sure if the balance should be stored in e.g. the users model itself, or if it is not stored but can be calculated any time based on the stored data / history. Some things to note, although I don't think that they should introduce problems:   * It does not have to be a `User`, it could be anything, that's why the `Subscriber` is polymorphic   * `Plans` do not necessarily have to be plans, but could be e.g. `Magazines` like mentioned. That's what I've described with _Case C_ and _Case D_.


title: Are side-effects in Array's "every", or "some" bad?

text: I've always been taught that having side-effects in an `if` condition are bad. What I mean is;               if (conditionThenHandle()) {         // do effectively nothing     }      ... as opposed to;               if (condition()) {         handle();     }      ... and I understand that, and my collegues are happy because I don't do it, and we all go home at 17:00 on a Friday and everyone has a merry weekend. Now, ECMAScript5 introduced methods like `every()` and `some()` to `Array`, and I find them very useful. They're cleaner than `for (;;;)`'s, give you another scope, _and_ make the element accessible by a variable. However when validating input, I more-often-than-not find myself using `every`/`some` in the condition to validate the input, then use `every`/`some` _again_ in the body to convert the input into a usable model;               if (input.every(function (that) {         return typeof that === "number";     })) {         input.every(function (that) {             // Model.findById(that); etc         }     } else {         return;     }      ... when what I _want_ to be doing is;               if (!input.every(function (that) {         var res = typeof that === "number";              if (res) {             // Model.findById(that); etc.         }              return res;     })) {         return;     }      ... which gives me side-effects in an `if`, condition, which is bad. In comparison, this is the code would look with with an old `for (;;;)`;               for (var i=0;i<input.length;i++) {         var curr = input[i];              if (typeof curr === "number") {             return;         }              // Model.findById(curr); etc.     }      * * * My questions are:   1. Is this definitely a bad practice?   2. Am I (mis|ab)using `some` and `every` ( _should_ I be using a `for(;;;)` for this?)   3. Is there a better approach?


title: Etiquette for editing someone's pull request

text: I own a repository on GitHub to which someone sent a pull request with one single commit. I only want to implement his solution partially, and use about half of the code changes the user made. What should I do in this situation? **Make a branch of his version, then go back and copy and paste the "old" code that I want to preserve from the original version into a second commit.** This may make the diff between commits look larger than it really is, and throw off things like `git blame`. **Copy and paste the code I want to keep from his commit into a new, different commit**. This means that he does not receive credit for his valuable contribution to the code. **Same as the above, copy some of his code into a new commit, but change the author of the commit to him instead of me**. He technically didn't write the _exact_ code that was committed, so I'm not sure if this is frowned upon. But at least he gets attribution for those lines that are used.


title: Structured programming versus OO programming

text: I am making a presentation that shows the differences between structural and object oriented programming and I want to illustrate **why** people need OOP with an example where applying OOP concepts will make coding much easier so that the audience really feel that they need OOP . Any Ideas ??


title: Console keyboard input OOP

text: I am trying to build a very simple console-based game with a focus on using OOP instead of procedural programming because I intend to build up on that code for more complex projects. I am wondering if there is a design pattern that nicely handles this use case: >   * There is a `Player` class with a `MakeMove()` method interacting with > the board game. > The `MakeMove()` method has to somehow get the user input yet I do not want to code it into the `Player` class as this would reduce cohesion and augment coupling. I was thinking of maybe having some controller class handle the sequence of events and thus the calls to keyboard input. However, that controller class would need to be able to handle differently the subclasses of `Player` (e.g. the `AI` class does not require keyboard input). Thoughts ?


title: Alternative approaches to usual software solutions

text: I am creating a service to be exposed on the internet. One of those things you would normally say "Web 2.0", but that I want to expose as a SOAP webservice, with desktop clients. I know that it may sound a little bit outdated, but despite the apparent "uncool" factor, is there any real reason why this approach shouldn't work? Yes, I will buy a VPS for this thing, it's an experiment for now - but who knows the future. I am just wondering, well, what you think of it :) Andrea


title: Creating Unit Tests on a CRUD layer of an Application, how can I make the tests independent?

text: So I'm trying to make my Unit Tests as by-the-book as possible, but it becomes troublesome when I'm testing some simple Add/Delete methods. For the add method, I basically have to create a dummy object and add it, then after the test is successful, I have to delete the dummy object. And for the delete test, I obviously have to create a dummy object so that I can delete it. As you can see if one test fails, the other will fail too, as they're both kinda needed. Same with a system where you would need to write a test that "Cancels an Order"...well some dummy order would be needed to cancel first, doesn't this go against the guidelines of unit testing? How are cases like this meant to be handled?


title: A progressive plan from vb6 to .net, sound?

text: We are about to start a new project using an existing SQL DB, but this project is going to need to reuse a number of core features from an existing vb6 app that uses the same database. The approach I would like to try: Have the existing vb6 application be the entry point, but immediately call a .net class to present the main screen and menu. If the user needs to use a feature/form that is in vb6 then raise an event to vb6 to load that form and hide the .net side of it until it's done. The alternative: Opposite of the above, create a .net exe to be the entry point and call a vb6 dll whenever I need a vb6 feature/form. Because of initialization that goes on in the vb6 app that makes various features usable, it would be much less painful for me to try the first approach. Moreover, there is some functionality that is very tightly coupled to the forms in the vb6 app and is vital to the application, but I will not be able to immediately port it to .net in the first phase. I realize this is not the ideal approach but unfortunately there are real world concerns that make taking the idealistic approach near (if not entirely) impossible. So my question is: are any specific pitfalls I should be aware of in doing this?


title: When to use repository pattern

text: I have read recently that it is not good practice to use the repository pattern in conjunction with an ORM. From my understanding this is because the abstraction they provide over the SQL database is too leaky to be contained by the pattern. I have a couple of questions about this:   1. What do you do if you want to switch out ORMs? You would have ORM specific code in your application if you do not contain it in a repository.   2. Is the repository pattern still valid when not using an ORM and you are using ADO.NET for data access and populating object data yourself?   3. If you use an ORM but not the repository pattern where do you keep commonly used queries? Would it be wise to represent each query as a class and have some sort of query factory to create instances?


title: How do I handle projects in which my project manager is the same as the client?

text: I am a freelance worker taking on a new project with a company I'm already familiar with. My boss (the company owner) previously gave me a website project to work at while he also assigns a project manager to review the progress. But with my latest project, the setup here is a little different. My boss assigned to me this project as well. He's only in the office two days out of a week. After the first meeting with the client, I wondered who was the PM since I wasn't introduced to him/her. When I told my boss that in most cases, I'd rather report to the PM because it's easier and more accessible, that's when he informed me there that **_my PM is the same person as the client!_** I was a bit shocked. I didn't want to tell him right out that I find something very wrong with that arrangement, but I'm stuck with this project for now. So I end up being in direct contact with the client once a week, which is good in a few cases, but am responsible for meeting him for extended periods while my boss only sits in for a few minutes. Especially for a project of a scope which will last for a few months, I feel like I'm doing the job of both a project manager and programmer. I didn't quote him for the project- the PM/client sent the quote to my boss, and my boss is handling my payouts based on that.** He also controls the schedule for the project. So I'm trying to tread carefully with completing the goals so I don't get short-changed. **My biggest concern, though, is the lack of good communication.** The PM/client is not very technically inclined, sometimes states goals that are subtly different from what I perceive, and asks for things that are beyond the means of the tools I'm working with. My boss is better at explaining the situation in a broad sense, but like I said he's not always available, and pretty slow at responding online. Basically, there's a lack of a dedicated PM and there is sparse communication among me, my boss and the PM/client. How would I track my own progress and ensure better performance, and avoid misinterpreting the tasks for the project? I want to stay on a good pace with the communication I receive without feeling stuck or overwhelmed. I prefer face to face contact. Everyone else in the office updates their progress by discussing with PMs working in the office on a daily basis, and their projects go more smoothly. My boss isn't interested in having one of them work on this project because he says it'll take a lot of time away from their current work. I want to force in more communication in this project but my boss isn't doing much to help. _[Edit]_ Well, here's an update. What ended up happening is that our client was demanding other features that turned out to be out of scope, and the CMS that we had to use didn't permit addition of these features so easily. My boss and I struck out some of his demands in the essence of time and budget, and last week the client/PM ended up being dissatisfied and cancelled the project indefinitely. In the future I will stay away from such arrangements with the client doubling as a PM. I think it gives someone far too much control over the direction of a project.


title: When do I need web services?

text: Are there any general guidelines to understand when I should consider using (as a eat-your-own-dogfood) and providing web services, and when I shouldn't worry about them? Or, any reading materials you can point me to? My project is in PHP but I don't mind if it's language agnostic.


title: Can you change code distributed under the MIT license, and re-distribute it under the GPL license?

text: Is it possible to alter the code of the Chili plugin, which had its latest release on July 2008, and it is licensed under the MIT license, to then license it under GPL? As far I can see, there is no restriction about the new code being licensed under the same license. Is it really so, or is there a minimum number of changes? In my case, I would change the jQuery plugin in normal Javascript code that is executed in a CMS. This essentially means that, among other things:   * The code will not use the "ChiliBook" namespace.    * The function will not be invoked as `$($element).chili()`, but as `GlobalObject.ChiliHighlighter.process($jquery_element)`, where "GlobalObject" is a JavaScript object used from the CMS.   * The code will allow other modules to alter the `GlobalObject.ChiliHighlighter` object to add functions that are optionally called from `GlobalObject.ChiliHighlighter.process()` when they are defined. As alternative, as the repository I am using allows me to include code not licensed under GPL 2 or higher license when the code is not maintained anymore, could the plugin be considered not maintained anymore, as its last version was released three years ago?


title: Is there a standard, formal name for an object or class that behaves as if it is a given object?

text: I have an app in Django that expects to get a record with the fields email, first_name, and last_name. However, sometimes I want to be able to send it something that isn't actually a record but behaves like one (in that it has the necessary fields as attributes), like so:               class FakeRecord(object):         def __init__(self, email, first_name=None, last_name=None):             self.email = email             self.first_name = first_name             self.last_name = last_name      I'm wondering if there is a standard name for this kind of object or if `FakeRecord` works as the name for this class. More generally, is there a name for a class that stands in for or behaves similarly to another class? Is there a standard implementation/design pattern? ## Further clarification For the purposes of my app, basically I have a utility function that sends an email to a recipient. The recipient can be any Django record so long as it has an email address, a first name, and a last name. However, sometimes the app sends a one-off mailing to some given e-mail address that doesn't have a record. In those cases, I simply create a FakeRecord with the email address (and first name/last name if available), and send that in instead. Since the utility function itself doesn't do anything with the record other than retrieving the attributes, none of the other db functionality of a Django record object is needed.


What's your favourite quote about programming? **One quote per answer** , and please check for duplicates before posting!


title: How much effort should be put in each part of a waterfall project?

text: Where waterfall commonly includes:   1. Requirements   2. Functional design   3. Technical design   4. Build   5. Test   6. Review   7. (Deploy) And iterations across this list. If I forgot a step, let me know.


title: How to manage product backlog/user stories

text: We're about to start a new project using Agile (using TFS), and I have a couple of "good practice" questions regarding the product backlog:- When we first start adding users stories, is it a good idea to put them in (say) a "Backlog" iteration, or just leave their iteration blank? Obviously when the time comes to start work on a US it would be moved into the appropriate iteration backlog. When breaking an epic down into smaller USs, would I simply close the original epic, as it's no longer required? Or should I create the new USs as children of the epic? (it's then someone's responsibility to close the epic once all child USs have been completed). Lastly, should the product backlog list all USs regardless of status, or only those that have not been started (i.e in my proposed "Backlog" iteration)? I realise these questions aren't life-or-death, but it would be nice to know how other people manage their product backlogs so we can organise things properly from the start.


title: How does a USB device whether know to draw 500mA, 1A or 2.1A from a computer USB port?

text: I'm having some issues with my Nexus 7 drawing just 500mA from a USB port able to supply 2.1A (test with my iPad). Details in **this question**. However, there is a comment posted " _The Nexus obviously detects the 'data' pin connected, and assumes it is not permitted to draw more than 500mA (which is the proper USB spec)._ " That got me thinking, how does a device really know how much it's allowed to draw from the USB port? It can't be just via wiring of the D+/D- pins because then you wouldn't be able to communicate over the USB port (eg. Sync'ing or transferring over the USB port). The iPhone and iPad clearly are able to draw higher power from the USB port even during a sync/data operation. So I was thinking, the power it might be officially dictated within the USB comm. protocol itself, perhaps some packet/header. So, **_how does a USB device know whether to draw 500mA, 1A or 2.1A from a computer USB port?_** Does the answer change if the USB port is on a "dumb" wall charger? Or is it a wild west where each device/charger does it's own thing for high current situations?


title: How to solve conflicts with another programmer

text: I've read this question, but I think it doesn't really applies in my case. I have issues working with another developer in my company and I'm not sure how to fix them when there is no team lead to help mediate or buffer our relations. Two months ago I was hired as a senior web developer. It's small company ( about 30 people ). The programming team is consisted by me and another programmer. This programmer is in a junior role, although he does not report to me. Ever since my first day, we've been clashing in various points. For example, he's refused to use a test server and a project management tool that I proposed to everybody and to which my boss agreed. He has also refused to compromise during discussions of best practices and coding standards. He is convinced that his way is the only true way to do things and doesn't take my arguments into consideration. He is even insisting that we are not a team and that I should just work on my projects and not bother him. He's also complaining about me to our boss. I'm passionate about improving our work environment and workflows. I try not force my opinions on others and always ask everybody what they think about it. Every new idea that I bring to the table is discussed and generally everyone works together to come up with a good compromise, except him. He's always negative and rejecting my proposals outright. I criticized his code shortly after starting at this company and that's a way to kill of a healthy relation. How can I approach resolving our issues?


title: Newbie, deciding Python or Erlang

text: I'm a Administrator (unix, Linux and some windows apps such as Exchange) by experience and have never worked on any programming language besides C# and scripting on Bash and lately on powershell. I'm starting out as a service provider and using multiple network/server monitoring tools based on open source (nagios, opennms etc) in order to monitor them. At this moment, being inspired by a design that I came up with, to do more than what is available with the open source at this time, I would like to start programming and test some of these ideas. The requirement is that a server software that captures a stream of data and store them in a database(CouchDB or MongoDB preferably) and the client side (agent installed on a server) would be sending this stream of data on a schedule of every 10 minutes or so. For these two core ideas, I have been reading about Python and Erlang besides ruby. I do plan to use either Amazon or Rackspace where the server platform would run. This gives me the scalability needed when we have more customers with many servers. For that reason alone, I thought Erlang was a better fit(I could be totally wrong, new to this game) and I understand that Erlang has limited support in some ways compared to Ruby or Python. But also I'm totally new to the programming realm of things and any advise would be appreciated grately. Jo


title: What are the most commonly used enterprise Java technologies, and what would you want a non technical audience to understand about them?

text: I have been asked to give a presentation to a non-technical audience on what Java technologies are currently being used in the enterprise world. The goal is to give this non-technical audience the background they need to understand what engineers are talking about. It's part of a broader series of talks that I'm giving. I'm primarily a .NET and C++ dev, so I thought I'd try to get some input from some Java devs. What technologies do you use? What Java related acronyms would you like to be able to use around non-coders? What would you like non-coders to understand about them?


title: When to use JavaScript instead of Ruby in web development?

text: Right now I am developing web applications with ruby-on-rails. Sometimes I am having a hard time deciding which language to chose to solve my problems. The difference between HTML,CSS and the programming languages is pretty clear. But when do I have to take JavaScript instead of Ruby (besides client-server difference)? Thanks!


title: Are there any programming languages that follow a minimalist development approach?

text: I find it that when languages are considered the same as commercial software, there is always a constant need to add new features to justify new releases. Can there be or are there languages where version 1.0 is the final version? Of course bug fixes are exempt from this, but the feature set always remains the same? This way every feature in the language fits together nicely and not seem like they are bolted on after the fact with obsolete features still around because of backwards compatibility. I assume some academic languages are like this? But are there commercially successful languages that follows this idea? The accompanying library is also free to get new features too, but the language always remains constant. One example I can give is, one of my favourite languages C#, which I use pretty often, more and more features are being added every release. To take advantages of these, I have to drop actual tasks in hand, and spend considerable time learning these instead of being able to pick up trivial concepts and combine those myself to solve more complex problems with ease. So I guess I am looking for a minimalist approach where everything is consistent, makes sense, and is as orthogonal as possible.


title: Working with shader code

text: I am starting my first project in OpenGL/GLSL and I was wondering, how do you work with code of shaders? Because it needs to be const char and syntax higlighting shows everything in the same color (as string) and so its difficult to navigate in code.               const char *shader = ..."void main()\n"...;      Do you edit the code and then add quotation marks or do you just write it with quotation marks from the start? Thanks edit: using VS2012


title: When should a database table use timestamps?

text: First a note, I thought maybe this question belonged in the database exchange, but I think it is more broadly related to a programming solution as a whole than to databases. Will move to database exchange if people think thats the best one. I was wondering when a database table should have a created and updated timestamp added? The first obvious answer is that if any business logic needs to know when something was updated (like a transaction completion date etc) then it must go in. But what about non business logic cases? For example I can think of scenarios where it would be really useful to know the date time that rows changed to help with fault finding e.g. some business logic is failing and looking at the related database rows its possible to identify that one row is being update before another row which is causing the error. With this use case, it would make sense to give every table an update and create timestamp (except for maybe the most trivial enum tables that wouldn't be updated by any part of the application). Giving every table a timestamp is surely a great way to quickly bog down a database (although could be wrong). So when should a database table use create and update timestamps?


title: What's the best way to build a factory using NInject?

text: I am pretty comfortable with dependency injection using NInject in MVC3. While working in an MVC3 application, I developed a custom Controller Creation Factory using NInject, so any controller that is created will have dependencies injected in it through this Controller Factory. Now I am starting to develop a windows application, I want to use Application wide Dependency Injection. i.e. Every object must be created through NInject, so as to ease Unit Testing. Please guide me to ensure that every object created must be though the NInject Factory only. For example, if on any windows form on `Button_Click` event I write:               TestClass testClass = new TestClass()      and `TestClass` has any dependency on, say, `ITest` then it must be automatically resolved. I know I can use:               Ikernel kernel = new StandardKenel()     //AddBinding()     TestClass testClass = kenel.get<TestClass>();      But I find it tedious to do this every time I want to create an object. It also the forces developer to create the object in a particular way. Can it be made better? Can I have a central repository for object creation and then every object creation will automatically use that repository?


title: Refactoring - Utility classes behavior under a common interface

text: I was suggested to put my question here, so I'm doing so ;) I need a common interface which represents some specific behavior:               public interface Contract(){        public void methodA();        public void methodB();        // and so on...     }      The problem is, that in order to fulfill this behavior, implementation can be totally stateless - it can have a private constructor and expose only static methods:               public class MyUtilityClass /*implements Contract*/{        private MyUtilityClass(){}        public static void methodA(){           // some implementation here...        }        public static void methodB(){           // some implementation here...        }     }      I have many such classes, with different behavior, so I want to refactor them and handle under a common interface. Because I cannot implement `Contract` by means of static methods, is the only solution to convert `MyUtilityClass` to a singleton which implements the interface in order to achieve my goal? Or maybe would you suggest something else? For example _Template method_ and _Strategy_ which can by injected depending on a specific situation? What would you propose?


title: Is there an Auto Generator for DataContracts?

text: Is there a tool out there that can quickly and simply generate a DataContract from either XML or JSON? Doing it manually can be a real pain.


title: Convert letters to numbers

text: I have the following problem. Given A=1, B=2 , ... , Z =26 I need an algorithm that given a letter combination, like the column order in excel, returns me the number/ AA=27 AB=28 ABC? Thanks a lot This is my algorithm so far, I dont like the switch inside the for. Any help is appreciate it, I will write it later in c#               Given A=1, B=2, Z=26. AB=27, ABC?     Variable = ABC     Positions =  Variable.Length -1     Int  result= 0     FOR (i=0; i<= Positions; i++)     {          Letter=Variable[i];         Switch(Letter)         Case A:             LetterValue=1          result=+ result+26*(LetterValue)^i     }


title: Am I wrong to disagree with A Gentle Introduction to symfony's template best practices?

text:
I am currently learning symfony and going through the book _A Gentle Introduction to symfony_ and came across this section in "Chapter 4: The Basics of Page Creation" on creating templates (or views): "If you need to execute some PHP code in the template, you should avoid using the usual PHP syntax, as shown in Listing 4-4. Instead, write your templates using the PHP alternative syntax, as shown in Listing 4-5, to keep the code understandable for non-PHP programmers." **Listing 4-4 - The Usual PHP Syntax, Good for Actions, But Bad for Templates**
Hello, world!
     <?php     if ($test) {        echo "
".time()."
";     }      ?>       (The ironic thing about this is that the echo statement would look even better if time was a variable declared in the controller because then you could just embed the variable in the string instead of concatenating) **Listing 4-5 - The Alternative PHP Syntax, Good for Templates**
Hello, world!
      <?php if ($test): ?>
<?php echo time(); ?>
<?php endif; ?>      I fail to see how listing 4-5 makes the code "understandable for non-PHP programmers", and its readability is shaky at best. 4-4 looks much more readable to me. Are there any programmers who are using symfony that write their templates like those in 4-4 rather than 4-5? Are there reasons I should use one over the other? There is the very slim chance that somewhere down the road someone less technical could be editing it the template, but how does 4-5 actually make it more understandable to them?


title: Coaxing requirements out of business people?

text: **What methods seem to work best to coax requirements out of non-tech business people?** I am working with a team that’s trying to get a spec together for a project. Every time we have met and it comes down to expectations for the next meeting, we ask for the business people to bring back their requirements. They usually respond something like this: “Well, do you think you guys could whip up a prototype so we can see what we like next week…you know, not with any data or anything since it’s a prototype, just the functionality.” This is a 6 month plus project so that is obviously infeasible (we would have to develop the entire thing!), and we don’t even know what to prototype without some sort of spec. Frankly, I think like most people, they have some idea of what they want, they just are not thinking about it in the focused sort of way necessary to gather true requirements. As an alternative to simply telling them, “give us what you want or we can’t/won’t do any work” (we do want them to be happy with the results), are there ways to help them decide what they want? For example, we could tell them: “Draw out some screens (in Powerpoint, on a napkin, whatever) that show the UI you would like with all of the data you want to see and a description of the functionality in the margins. From this, we will polish it up and build the backend based on this set of behavior requirements.” OR “Don’t worry about how it will look right now (the number 1 hang up). Just give us a list of all the data you want about each thing the program keeps track of. So for “Customer” you might list: name, address, phone number, orders, etc. It does not have to be a perfect database structure, but we can work something out from this and get an idea of what you are looking for” **Do either of these alternative approaches to get business people focused on what they want make sense? Are there alternatives that you have seen in action?**


title: When and why should one create classes at runtime?

text: I have read many articles on the creation of dynamic types and classes at run time. For example, the `TypeBuilder` class in C# lets one create dynamic types. Python has this type function by which one can create dynamic classes. I have certainly good information on how I should create a class at run time, but I don't find enough information on why I should do this. What is a scenario where one would be forced to create types at runtime?


title: What's the difference between recursion and corecursion?

text: What's the difference between these?   * Recursion   * Corecursion On Wikipedia, there is little information and no clear code explaining these terms. What are some very simple examples explaining these terms? How is corecursion the dual of recursion? Are there any classic corecusive algorithms?


title: Aggregate Boundary repository/service design

text: I am trying to apply DDD to the design of a Release Management system. ## **Domain Entities**   * `Project`: The project/product/system.   * `ProjectEnvironment`: The environments (Test, Staging, Prod) that exist for this project. Each project has its own defined environments.   * `ProjectVersion`: A specific version of the project. This would be associated with a deployment package. ![Class diagram of entities](http://i.stack.imgur.com/rJhEW.png) ## **Aggregate Boundary** From this I would have `Project` be the aggregate root and `ProjectEnvironment` and `ProjectVersion` be aggregates of `Project`. Neither of these can exist without `Project`. ## **Repository** I would then only have a `ProjectRepository` which would provide persisted `Projects` with all the included `ProjectVersion` and `ProjectEnvironment` aggregates (and consequently can only be accessed through their respective `Project`). ## **Questions**   1. Should there be a `VersionRepository` and a `EnvironmentRepository`? A `GetVersionById()` method on the `ProductRepository` sounds wrong. But then wouldn't supplying multiple repositories threaten the aggregate boundary?   2. Should there be a 'ProjectService' which would handle and validate the aggregates using the three repositories? In order to safeguard against invalid data, client code would only be able to reference the 'ProjectService'.


I'm trying to understand the theory behind a lexer with the purpose of building one (just for my own fun and experience and to compensate for not taking proper CS courses :)). What I have yet to understand is if lexer theory is the same no matter what language you are analyzing? Is it just about splitting white space then try to figure out what each text represents or is it more than that? In other words, does the generation of tokens depend on the language being analyzed or is it just about white space? Can you apply the same lexer rules to all programming languages? For example if I have a lexer that tokenizes Java code can I use it for Python or not, since whitespace in Python has other meaning? For example, I found a nice Python project (Pygments) which seems to provide a working core that allows you to later plugin rules for each of your favorite language (what are the keywords, the comments etc).


title: Continuous Delivery: Kanban, SCRUM, or other?

text: I was wondering if there was an SDLC (software development lifecycle) or methodology (Kanban, SCRUM, waterfall, otherwise, etc.) that was particularly well-suited for continuous delivery systems, and why? I'm sure each methodology has pros/cons that make it suited for certain _components_ of CD, but there must be one that incorporates principles/values that make it better geared for CD...


title: Do you write titles in code comments?

text: I was browsing some old code that I wrote (first year in the university) and noticed that I used to write comment titles preceeding various parts of the code. Stuff like (this is from a Monopoly game):               /*Board initialization*/     ...code...          /*Player initialization*/     ...code...          /*Game logic starts here*/     /*Displaying current situation*/     ...code...          /*Executing move*/     ...code...          /*Handle special event*/     ...code...          /*Commit changes, switch to next player*/     ...code...      This might be redundant, and arguably unnecessary if the code is really super clear, but as I scanned through the file it surprised me how strongly I felt like I know what's going on even though I hardly looked at the actual code. I can definitely see this as being fitting in certain circumstances, so I wonder- do you do this? Do you think it's a good idea? Or is it too much?


title: Best practices for using namespaces in C++

text: I have read Uncle Bob's Clean Code a few months ago, and it has had a profound impact on the way I write code. Even if it seemed like he was repeating things that every programmer should know, putting them all together and putting them into practice does result in much cleaner code. In particular, I found breaking up large functions into many tiny functions, and breaking up large classes into many tiny classes to be incredibly useful. Now for the question. The book's examples are all in Java, while I have been working in C++ for the past several years. How would the ideas in _Clean Code_ extend to the use of namespaces, which do not exist in Java? (Yes, I know about the Java packages, but it is not really the same.) Does it make sense to apply the idea of creating many tiny entities, each with a clearly define responsibility, to namespaces? Should a small group of related classes always be wrapped in a namespace? Is this the way to manage the complexity of having lots of tiny classes, or would the cost of managing lots of namespaces be prohibitive? Edit: My question is answered in this Wikipedia entry about Package Principles.


title: Why does division and multiplication by 2 use the shift operator rather than division operator?

text: While looking at the code in C for division/multiplication by 2, it is found that shift operator is used rather than division operator. What is the advantage of using shift over division operator?