Solving point in interval queries

There are n intervals given by starting (a[1], a[2], ..., a[n]) and ending points (b[1], b[2], ..., b[n]) and m queries of the form: given an integer x find the indices of the intervals which contain x. This can be written as S(x) = {k | 1 <= k <= n and a[k] <= x <= b[k]}. What is the fastest algorithm/data-structure (please, if possible, give references to implementation/documentation) to solve these queries? I'm positive that interval trees should solve the problem, but I'm not really sure on how should I approach the returning of the results. Until now, I could produce the following methods, but all seem quite slow.   * Naive approach: for each query go through all the intervals and see if the point is in the respective interval   * Sort the intervals by their starting point (and then ending point) and binary search for a lower bound on the starting point, then iterate to right checking the condition.


Partitioning code into assemblies for the sake of logical seperation

I've started working at this company, and the software is managed in a Visual Studio solution that includes hundreds of projects (C++ and C#). After poking around the solution for couple of weeks, I started wondering why there are so many projects. Not only does it slows down VS considerably, but a rebuild can take up to an hour. Since a visual studio project corresponds to a physical deployment unit (be it a .NET dll, a C++ lib or an exe), there are reasons why you'd want code partitioned across projects. Some of those reasons can be found in this article. In my particular case, none of the reasons in that article stood. There are roughly 5 processes running across tiers, maybe a few dynamically loaded assemblies used for a plug-in model, and some infrastructure which is rarely changed. I don't see any need for more than ~50 VS projects for this solution, and I believe that merging them will increase productivity and will allow for a shorter feedback loop. When I tried to suggest this to the software manager, his response was that they are trying to have **as many dlls as possible** so that when they plan to ship a new feature, **QA can test just the behavior of the modified dlls** without having to worry that something else was effected. He said that since a dll was not changed, it will behave the same. For this to work they aim for high granularity of deployment units. Does this make sense to anyone? I don't see the difference in the effect on behavior between editing a single line in a project that has a single huge dll, and editing the same line in a project that includes hundreds of dlls. **EDIT** I'm looking for an answer on using assemblies/project as means for separating logical concerns and its effect on the testing effort. I would even go as far as saying that many assemblies that could give you more testing scenarios because of versioning incompatibilities. So my distilled question is: When will you partition your code across projects/assemblies instead of namespaces in the same assembly, given that there are no runtime constraints, and why? **EDIT 2** I guess I'm looking for something like this article. However, I'm reluctant to post this as an answer and accept before I see if there are different opinions in the community.


Rails Document Conversion Suggestion?

I am currently learning rails, day to day, and I get more attached. I would like to use Rails to build a Web app with similar functionality like Scribd or Docstoc. What components/gems/plugins/libraries in Rails or Ruby could be used to create a web app with similar functionallity ? The web app should be have the   * Epub coversion to image(jpeg) as well as pdf   * PDF conversion to image (jpeg) as well as epub   * PDF to Epub I would just like suggestions on the libraries or plugins, etc... to use to obtain the above functionalities using Rails, and what makes them special.


Fast extraction to text file from oracle database

I have to extract around 3 million records from two different databases for further processing. Currently, I execute the queries via SQL*Plus and spool the results to a plain text file. This queries take around 10 minutes each (it's faster on one of the databases) but im looking to improve those times. I found this tool: http://www.iri.com/products/FACT that's supposed to do exactly what I need. Do you know about any other open source tool that I can use to help me improve the extraction times, or maybe a better technique than just spooling to a text file?


What is the object-oriented thought process?

I've been studying OOP in conjunction with Zend's MVC implementation for the past few months. I'm pretty new to programming, generally, but I feel strongly that I should learn things the 'right' way, which for me means to make sure I understand _why_ things are done the way they are. I.e., I have found that in learning how to do something (anything, say music), the best way to learn how to do something is to know why it's done that way in the first place. Anyway, I have been struggling very hard with understanding how to develop my own business models (i.e., the M of MVC), and I have decided it's not because I don't understand OOP in general, because I've studied it for several months and I don't think the concepts are very difficult to grasp. I find the examples I've studied very intuitive, actually. The problem for me, I think, lies in the process of translating my own problems into object oriented solutions. The examples in books (that I've read so far) are too obvious, so the process of translating the problem into objects isn't very difficult. What I think I might be missing is a high-level abstracted process. Some kind of list of steps or questions that every object-oriented solution must answer on the highest level. If you had to describe such a process in no more than five steps, what would they be and why? What is the most effective process in translating any problem into an object-oriented solution?


Multiple readers on FIFO

I've asked a question here before about multiple writers on a FIFO, and I know now that the write is thread safe as long as I write less than the PIPE_BIF, here is the link for that limit. What about read? what if have two(or more) readers in multiple threads for reading from the same fifo, do I need locks here? or all I need is to read less than the PIPE_BUF? BTW, I'm talking about Linux FIFO, And I'm using C.


How does the GNU General Public License (GPL) conform to the Open Source Initiative's (OSI) Open Source Definition (OSD)?

From the OSI's OSD: >   1. Free Redistribution > > > The license shall not restrict any party from selling or giving away the > software as a component of an aggregate software distribution containing > programs from several different sources. The license shall not require a > royalty or other fee for such sale. and >   3. Derived Works > > > The license must allow modifications and derived works, and must allow them > to be distributed under the same terms as the license of the original > software. If the license is GPL then point 3 would suggest that derived works must be distributed under the GPL too, which is the intention of such a 'viral' license. Taken together with point 1 though there seems to be a contradiction, as the GPL specifically restricts you from selling the software. As the OSI lists the GPL as OpenSource I must be missing something. Can anyone explain? EDIT: The FAQ section of the OSI site seems to speak to this issue but I am still unsure about their answer. I think this should mean that you can use GPL code in software that you sell as long as you also provide on request the new source code. However section 9 says: >   9. License Must Not Restrict Other Software > > > The license must not place restrictions on other software that is > distributed along with the licensed software. For example, the license must > not insist that all other programs distributed on the same medium must be > open-source software. Is the distinction here that derived software must be under the same license (point 3) but 'packaged with' is ok to be under a different license? I'm not quite sure what "distributed on the same medium" means.


Should we rewrite it from scratch

At work, we have a software written in PL/SQL - Oracle Forms 10g, which runs the software as a Java Applet. My Company bought the software and we have to develop the software, but we feel that Oracle Forms 10g Technology with Java applet is out of date. It's a technology from the past decade and we must move the software to a different platform (ie. Web or some other platform). Is this a good or bad idea? And why?


Collection providing lookup by one of several keys

What do you call a collection in which each item may be looked up by **one** of multiple keys? A partial, simplified definition in C# might be:               class MyDataStructure<TKey1, TKey2, TValue> {         private List<TValue> _values;         //map keys to indices         private Dictionary<TKey1, int> _keys1;         private Dictionary<TKey2, int> _keys2;              public TValue GetByKey1(TKey1 key) ...         public TValue GetByKey2(TKey2 key) ...     }      There's `MultiKeyMap` in Java, but that seems to lookup items based on a combination of keys, not by **each key individually**. Does what I've described have a well-established name? ### EDIT If there's not an established name, feel free to offer a new one. Or state your preference for one of these:   1. ChoiceKeyDictionary   2. AlternateKeyDictionary   3. DualKeyDictionary


Is it a bad practice to modify code strictly for testing purposes

I have a debate with a programmer colleague about whether it is a good or bad practice to modify a working piece of code only to make it testable (via unit tests for example). My opinion is that it is OK, within the limits of maintaining good object oriented and software engineering practices of course (not "making everything public", etc). My colleague's opinion is that modifying code (which works) only for testing purposes is wrong. Just a simple example, think of this piece of code that is used by some component (written in C#):               public void DoSomethingOnAllTypes()     {         var types = Assembly.GetExecutingAssembly().GetTypes();              foreach (var currentType in types)         {             // do something with this type (e.g: read it's attributes, process, etc).         }     }      I have suggested that this code can be modified to call out another method that will do the actual work:               public void DoSomething(Assembly asm)     {         // not relying on Assembly.GetExecutingAssembly() anymore...     }      This method takes in an Assembly object to work on, making it possible to pass your own Assembly to do the testing on. My colleague didn't think this is a good practice. What is considered a good and common practice ?


What would your DB Schema look like if you are building a Reddit/Digg-like site?

Just found out something rather interesting about Reddit's database schema: > The way we’ve changed is we use an “open schema”. Sometimes it’s called > “entity attribute value”. It’s basically a large key value store. We have > two types of tables for every data type. There is a “thing” table, and then > a “data” table. Everything in Reddit is comprised of what we call things: > users, links, comments, sub-Reddit’s, awards. > > Everything on Reddit is a thing. The schema for those elements look the > same. It looks like this top table here: ups, downs, a type, a creation > date, some properties that are fundamental across all of the objects in > Reddit. > > Then we have what’s called the “data” table, which is basically this huge > table with three columns: the thing idea we’re talking about is the left- > most column, then a key, and a value. For example, these two links would be > represented by two links in a thing table, and then one row in the data > table for every value on that link. There would be a key for title, and a > value for that title for that link; and a key for URL and a key for the > author, and then a key for how many spam votes that are on it. Source: http://thinkvitamin.com/code/steve-huffman-on-lessons-learned-at- reddit/ So I started looking around to see what other similar sites are doing. Could not find anything about Digg. SO is doing something more traditional with a Users, Posts, Comments, Badges and Votes table. DotNetKicks and DotNetShout do similar (tradional) things. So I wanted to ask the SO community, if you were designing a site like Reddit or Digg or even SO (basically any social voting sites) using ASP.NET MVC and SQL Server, what would you do? How would you design it?


.Net Application & Database Modularity/Reuse

I'm looking for some guidance on how to architect an app with regards to modularity, separation of concerns and re-usability. I'm working on an application (ASP.Net, C#) that has distinctly generic chunks of functionality, that I'd love to be able to lift out, all layers, into re- usable components. This means the module handles the database schema, data access, API, everything so that the next time I want to use it I can just register the module and hook into it. Developing modules of re-usable functionality is a no-brainer, but what is really confusing me is what to do when it comes to handling a core re-usable database schema that serves the module's functionality. In an ideal world, I would register a module and it would ensure that the associated database schema exists in the DB, by creating the schema if it didn't already. I would code my dependent functionality on the assumption that the tables exist calling the module's functionality through the DLL, agnostic of the database layer. Kind of like Enterprise Library's Caching/Logging Application Block, which can create a DB schema in the target DB to use as a data store. My Questions is: What do you think is the best way to achieve this, firstly, in terms design architecture, and secondly solution structure. What patterns/frameworks do you know that exist & support this kind of thing? My thoughts so far: I mostly use Entity Framework and SQL Server DB Projects. I thought about a 'black box' approach to modules of functionality. I could use use a code-first approach in EF4, and use the ObjectContext to create a database when the module is initialized. However this means that all of the entities that my module encapsulates would be disconnected from the rest of the application because they belonged to an abstracted ObjectContext. Further - Creating appropriate indexes and references between domain entities and the module's entities would be impossible to do practically. I've thought of adopting Enterprise Library and creating my own Application Blocks. I'm not sure how this would play nice with Entity Framework (if at all) though. I like the idea of building on proven patterns & practices to encapsulate established, reusable functionality. I thought of abandoning Entity Framework for the Module, and just creating a separate DB schema for the module with its own set of stored procedures & ADO.Net. Then deploying the script at run-time if interrogation shows that it doesn't exist. But once again, for developing functionality outside of the module, I would want to use Entity Framework and I would have to use the module separately, disconnected from the domain ObjectContext. Has anyone had experience developing these sorts of full-stack modules? What advice can you offer? Am I biting off more than I can chew?


I need a JavaScript runtime environment

I'm reading books on JavaScript programming, and I need an environment like Python's IDLE to type JavaScript commands into and then see the results like you would in IDLE. Is there an environment where you can do such a thing?


Zend framework 2 authentication - only storing the user ID in session

I've just put together my first app using Zend_Authenticate. According to some tutorials I've read they store the user's "email" column. Is this recommended? I've read to store the ID only, then on each request fetch the user by ID. That way, only the ID is stored in the session. Is this recommended with Zend too? Anyway here is my handling of user login, I'd appreciate any feedback. Basically I'm authenticating. If that passed, I then store the ID in auth storage and a custom flash message. The script then redirects to the homepage (upon which the login form will be replaced with a user panel - e.g. "Welcome back John" - and my flash message will display. Below is my loginAction method:               public function loginAction()     {       $form = new LoginForm();            $form->get('submit')->setValue('Login');            $request = $this->getRequest();            if ($request->isPost()) {                // check the users credentials and authenticate           $this->getAuthService()             ->getAdapter()             ->setIdentity($request->getPost('email'))             ->setCredential($request->getPost('password'));                $result = $this->getAuthService()->authenticate();                if ($result->isValid()) {                  // set the user id in storage             $resultRow = $this->getAuthService()->getAdapter()->getResultRowObject();             $this->getAuthService()->getStorage()->write($resultRow->id);                  // set flash messenger             $this->flashMessenger()->addMessage('You are now logged in');                  // redirect to the home page             return $this->redirect()->toUrl('/');           }            }              return new ViewModel(array(           'form' => $form,         ));       }          }


How to handle estimates for programmers joining the team?

Iteration has already started, new programmer joins the team, task X has already been estimated to be 30 hours by a different developer. What is the best practice in this situation?   * new developer runs with the given estimate (the idea being that any discrepancy will be corrected for when velocity is calculated?)   * new developer re-estimates task? (if so, what if it's significantly higher and no longer fits in the iteration?)   * throw our hands up and go back to waterfall?   * something else entirely?


Quality of Code in unit tests?

When writing unit tests, is it worth spending the extra time to make the code have good quality and readability? When writing tests I often break the Law of Demeter, for faster writing and to avoid using so many variables. Technically, unit tests are not reused directly - they are strictly bound to the code so I do not see any reason for spending much time on them; they only need to be functional.


How much code does one have to derive from another source before the license rules are applicable?

In an attempt to not re-invent the wheel, I've been working on a CMS's text- sanitization layer. I found that SimplePie had a really good one in use with it's RSS feed, but it had a lot of features that I didn't need (such as image cache-ing, making relative urls absolute, etc.) so the actual amount of code that I'm using that's more-or-less a direct copy of SimplePie's code, is maybe 20-30% of the original `SimplePie_Sanitize` class code. My question is, since it's not exactly a direct copy (agree'd there are parts that are, and parts that aren't as I had to bring it up to PHP 5.3.6 spec and what-not), how much of the code _has_ to be a direct copy for the BSD license (which SimplePie uses) to apply? Keep in mind I'm going to be adding some of my own things into the code as well to help prevent XSS attacks so the class will eventually may only be 50% original, and 50% of the copied (or at least, the 20-30% that's left of it). With that: **is a simple 'THIS HAS CODE FROM THIS PROJECT' disclaimer enough, or do I have to apply the BSD license to the _entire_ code file?**


How could dependency injection be integrated into the language?

I've been thinking a bit on how dependency injection could be better integrated directly into a C# like language. I've come up with a potential solution I'd like to hear your opinion on. I haven't used many dependency injection frameworks so there might be something I'm overlooking Anyways, the idea is the be able to declare properties as "injectable" using a keyword. When an object is instantiated and that property is not initialized through the constructor or object initializer it requests an instance of that property type from some global service. Similarily you register handlers for different types to that service so that you can instantiate the injected property type. The upside of using this kind of architecture IMO is that it's fairly flexible and easy to use. The downside is that there might be some overhead of doing the callout to the singleton each time you initiate a class that has injection. Then again that's only an issue for classes that get's instantiated frequently in a high performance solution so it shouldn't be much of an issue. Perhaps you could use some kind of factory in those instances. Thought, issues, questions, better ideas? **Code**               public class SomeClass     {            public SomeClass()       {          //implicit behavior if Animal is not set in constructor or initializer         this.Animal =  GlobalInjector.Get(this,typeof(Mammal))            }            public injectable Mammal Animal         {        get;        set;       }     }                GlobalInjector.Register(typeof(Mammal), () => return new Mammal(someParameter));


I need quick start to Java, Apache, and Java web based apps to use JasperReports

Sorry, it is **NOT** duplicated question, just read it please, I'm totally new to Java world, I'm a .NET developer, and I have a good exprience in ASP.NET. Now I have a task to make a demo for JasperReport, I need **QUICK** start to Java and Java web application on Apache and then I will figure out how to use _JasperReport_. Thank you very much people,


Naming conventions and organization of packages

I've been programming in Java, C#, Python and AS3 most of the time and in all of these languages there are _packages_ (or something like that). The problem I found is with the naming convention, or even with the organization of the packages. I need someone to tell me WHY is this: `com.company.app.type.Object` or `org.authorname.project.type.Object` better than this: `app.feature.Object` or `app.module.Object` * * * Another example: Why this:               com      +--company          +--app              +--events              |   |--FeatureOneEventA              |   |--FeatureOneEventB              |   |--FeatureOneEventC              |   |--FeatureTwoEventA              |   |--FeatureTwoEventB              |                 +--models              |   |--FeatureOne              |   |--FeatureTwo              |                 +--services                  |--FeatureOneServiceA                  |--FeatureTwoServiceA                  |--FeatureTwoServiceB      Is "better" than this:                company       +--app           +--feature               +--one               |   |--Model               |   |               |   +--events               |   |   |--EventA               |   |   |--EventB               |   |   |--EventC               |   |               |   +--services               |       |--ServiceA               |                 +--two                   |--Model                   |                   +--events                   |   |--EventA                   |   |--EventB                   |                   +--services                       |--ServiceA                       |--ServiceB      In the first one you have all organized by "types of objects", but the "features" are all mixed, but in the second one, the organization is by "feature" and each one has their own objects; so, you can see one feature well separated from another. So, can anyone tell me why a lot of companies and programmers prefer the first? PS: Sorry for my poor English


Document-oriented vs Column-oriented database fit

I have a data-intensive application that desperately needs a database make- over. The general data model: There are records with RIDs, grouped together by group IDs (GID). The records have arbitrary data fields, (maybe 5-15) with a few of them mandatory and the rest optional, and thus sparse. The general use model: There are LOTS and LOTS of Writes. Millions to Billions of records are stored. Very often, they are associated with new GIDs, but sometimes, they are associated with existing GIDs. There aren't as many reads, but when they happen, they need to be pretty fast or at least constant speed regardless of the database size. And when the reads happen, it will need to retrieve all the records/RIDs with a certain GID. I don't have a need to search by the record field values. Primarily, I will need to query by the GID and maybe RID. What database implementation should I use? I did some initial research between document-oriented and column-oriented databases and it seems the document-oriented ones are a good fit, model-wise. I could store all the records together under the same document key using the GID. But I don't really have any use for their ability to search the document contents itself. I like the simplicity and scalability of column-oriented databases like Cassandra, but how should I model my data in this paradigm for optimal performance? Should my key be the GID and should I create a column for each record/RID? (there maybe thousands or hundreds of thousands of records in a group/GID). Or should my key be the RID and ensure each row has a column for the GID value? What results in faster writes and reads under this model?


How to organise projects with dependencies on BitBucket?

Both Mercurial and BitBucket make one fundamental assumption: 1 repo = 1 project. If I have a project that has a dependency (a library) which is shared by many projects, this assumption gets in the way. Now it is no longer possible to have a separate BitBucket page for each project while still being able to commit atomic revisions to multiple projects. If I put all the projects into one repo, they all become one “project” on BitBucket. If I put them in separate repos, it is no longer possible to know which version of the library project was in use at revision X of a dependent project. How is this situation normally solved on BitBucket, or is there explicitly no support for this common scenario?


How competitive are Software Engineering startup jobs?

Background: I've worked in a quantitative financial consulting position for the past 4-5 years (financial modeling with Matlab, VBA, Excel mostly). I have a degree in Computer Science (BA) and Math (BA). I'm want to join a startup company to realign my career with my passion: technology. I lack the official "software development" (SDLC) experience but have very much programmed for work and personally (Python, PHP, C++, etc). Question: How competitive are software engineering positions in startup companies? Will I be hard pressed to find someone who will hire me not having "official" software development experience? Does anyone have any tips for me in achieving my goal?


Random number generation algorithm for human brains?

Are you aware of, or have you devised, any practical, simple-to-learn "in- head" algorithms that let humans generate (somewhat "true") random numbers? By "in-head" I mean.. preferably without any external tools or devices. Also, a high output (many random numbers per minute) is desirable. Asked this on SO but it didn't get much interest. Maybe this is better suited for programmers.


What is the motivation behind TypeScript?

We had JavaScript, then we had Flash, then we had Silverlight and then HTML5 ownd them all. So what is the motivation behind TypeScript? What problems are going to be tackled and what improvements do we get with TypeScript? http://www.typescriptlang.org/


Is there any specific reason to use "else if" clause?

We all use if ..else if.. else. But still I'm confused as to why we use **else if**. Where **if** does the same thing as **else if**. So why are we using **else if**? Any specific reasons behind this? Is there any algorithm where it's mandatory to use **else if**?


How to organize a set of syntax highlighting classes?

I am creating a set of syntax highlighters for an application. The languages include:   * HTML (specifically HTML5)   * JavaScript   * PHP   * CSS (specifically CSS3) The problem lies in the way the classes need to be organized. Since this is a Qt application, each language has its own class which derives from QSyntaxHighlighter. Each class overrides `highlightBlock()` which is responsible for coloring the supplied block of text. JavaScript code can be contained in `.js` files as well as inside `<script></script>` tags. Similarly CSS styles can be contained in `.css` files as well as inside `<style></style>` HTML tags. To top it all off, HTML content can be found in both `.html` and `.php` files. Each language has its own file extension and therefore requires its own class. **However,** since certain languages can be embedded within one another, there needs to be a way to avoid duplicating code. In other words, it makes no sense having the JavaScript parsing code inside the HTML highlighting class _and_ the JavaScript highlighting class. What would be an ideal way of organizing the code? Here are some options that come to mind:   * **Abstract the parsing code completely.** This option would involve removing the parsing code for each language from the syntax highlighting class for that language. Then the parsing code could easily invoke other parsers as necessary. This option sounds good but would be very complex.   * **Use inheritance.** This option doesn't sound like a good idea, but I thought it was worth mentioning anyway. In this case, I would have a `PHP_SyntaxHighlighter` class that derives from `HTML_SyntaxHighlighter` which in turn derives from both `JS_SyntaxHighlighter` and `CSS_SyntaxHighlighter`. The idea is that the container classes (like HTML) could invoke the overridden method in the base class when necessary. This option involves multiple inheritance and therefore will not work with Qt - thus, it's not really a true option.   * **Create instances of the other classes and invoke the`highlightBlock()` function.** This option would involve constructing instances of other classes and then invoking their syntax highlighting function for the given language. This is probably quite difficult to implement as well and would involve a lot of hacking. So these are the options I'm looking at. I welcome any suggestions, pointers, or tips for organizing these classes.


How to go about building a website that allows users to deposit/transfer money?

Can someone help me understand the process one would have to go through to set up a website, like a job board, that allows users to deposit money into their account and then use it to buy/sell stuff? Is it possible to use Paypal as Escrow the same way Ebay does?


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

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?


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

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)?


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

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.


Is distributing patches in compliance with the GPL?

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?


How do you support your code post employment end?

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.


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

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...


backup visual studio folder and sql database

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.


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

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.


Getting Involved?

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!


Open Source - First Project

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.


Unit Tests for Database Abstraction Layer

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.


Source control system for binary files

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


How are Scala Traits implemented in the JVM?

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?


Preferring Database Normalization vs. Schema Transparency?

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.


Adapting to a team environment after developing alone for years

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.


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

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?


Guess if a time is AM or PM

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.


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

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?


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

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?


Is there a scalable multi-site strategy with codeigniter?

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?


Understand scripting language

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!


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

**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!


Industry jobs in artificial intelligence

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!


Distributed SCRUM team issues: The work environment

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.


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

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?


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

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.


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

### 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?


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

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?


Ideal way to define a table or grid in XML?

## 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">`


Convince someone that an app cannot be done

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?


Should I use abstract or virtual methods?

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         //////////////////////////////////////////////     }


Why not write all tests at once when doing TDD?

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.


Using Cucumber with Page objects

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?


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

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?


Managing references in open source .NET project?

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?


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

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)?


Objective-C message passing related queries

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?


Should I expose IObservable<T> on my interfaces?

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.


What is a good pattern for combined caching and reinitialization?

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).


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

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?


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

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?


Equivalent of #map in ruby in golang

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 !


How can test users access an unpublished iOS app?

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?


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

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.


Handling subscriptions, balances and pricing plan changes

**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_.


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

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?


Etiquette for editing someone's pull request

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.


Structured programming versus OO programming

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 ??


Console keyboard input OOP

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 ?


Alternative approaches to usual software solutions

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


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

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?


A progressive plan from vb6 to .net, sound?

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?