title: Developing a simple web-application?

text: I decided to do a mini-project by myself to help me understand a bit more about developing web applications before starting the new university semester. Using the Java SE and JEE/J2EE platforms. I will be creating a simple web application that will retrieve data from a database and display the data. I decided to use a Model-View-Controller type pattern and so far decided that the: Models: Will be Java objects which are persisted in the database using a framework. View: will only be the front end, probably written in HTML with some CSS. I have not (at a high level) decided how the controller should be implemented, I initially went along with the idea that I will use JDBC to query results from the database and display it to the front end but the use of frameworks should ease the process. I was told that there are some open source frame-works that help in making web application and a few I looked up were Spring and Hibernate. My question then is there a way of incorporating these frameworks to what I proposed and if so how can I learn about these frameworks in order to create a web application? Would appreciate advice and experiences about developing web-applications. This is something I have not done before so it’s all a new and a learning process for me. In essence I want to create is a web-application using Java as the primary programming language in which database querying functionalities help in displaying outputs to the front end. **Edit:** Edited question to make it clearer for those who want to start similar type projects.


title: Manufacturing vs Software Development

text: It's often said that the software industry is immature compared to manufacturing. Specifically with regard to being process driven. **Question** : Can we as developers learn from the processes of the manufacturing industry? Can adopting their processes increase the success rate of software development? **My take** : In manufacturing the creation of a product is heavily process driven. You may have a factory where each person has a specific set of tasks they follow. A worker (or robot) may tighten a screw all day long. Then the next task in the process is performed by the next specialist. The workers (and robots) do not deter from the process or make something up "on the fly". The parts churn through the through the process, and the output is a finished product. It works well and companies achieve 99.99966% defect free products. Companies iron out inefficiencies over time. This is impressive and very well may be the sign of a mature industry. In manufacturing a defined process can literally create the finished product. I don't think this is the case in software. We may have processes for source control, code review, check in sheets, requirements gathering, the SDLC, etc. But executing those processes does not in and of itself create a finished product. These processes may be beneficial, but are orthogonal to the actual creation. Suppose your company is contracted to create software that will search millions of images to find the faces of a criminals. Despite the heavy process driven environment, the developer must engage in creating things "on the fly". Doing things on the fly is against the spirit of manufacturing. A good manufacturing process can be executed without thought by a robot. For the creation of complex algorithms which have yet to be fathomed in the mind of a human, it is a necessity to create things on the fly. Software development is not the following of a process, but the creation of a processes to be exucuted by a computer. That is a fundamental difference. No matter how many orthogonal processes we put up around development, we will always resort to doing it "on the fly" when it comes to creation. Everyone I talk to seems to agree with the manufacturing mindset. Am I alone in my thoughts? **Edit** : I have accepted an answer. And my mind is made up. [start lecture] I declare the field of Software Engineering has grossly misunderstood the nature of processes. A process is a set of steps. If something can be expressed as a set of steps, it can be automated (or at least the high level aspects can be applied by rote). Automation cannot perform original creation, therefore all processes are orthogonal to creation. I think our best bet is to come to terms that the processes that we adopt are orthogonal. We can never grow out of our "immaturity". It is the physics of creation that will keep us perceived as immature forever. [/end lecture]


title: Code structure for multiple applications with a common core

text: I want to create two applications that will have a lot of common functionality. Basically, one system is a more advanced version of the other system. Let's call them `Simple` and `Advanced`. The `Advanced` system will add to, extend, alter and sometimes replace the functionality of the `Simple` system. For instance, the `Advanced` system will add new classes, add properties and methods to existing `Simple` classes, change the behavior of classes, etc. Initially I was thinking that the `Advanced` classes simply inherited from the `Simple` classes but I can see the functionality diverging quite significantly as development progresses, even while maintaining a core base functionality. For instance, the `Simple` system might have a Project class with a Sponsor property whereas the `Advanced` system has a list of Project.Sponsors. It seems poor practice to inherit from a class and then hide, alter or throw away significant parts of its features. An alternative is just to run two separate code bases and copy the common code between them but that seems inefficient, archaic and fraught with peril. Surely we have moved beyond the days of "copy-and-paste inheritance". Another way to structure it would be to use partial classes and have three projects: `Core` which has the common functionality, `Simple` which extends the `Core` partial classes for the simple system, and `Advanced` which also extends the `Core` partial classes for the advanced system. Plus having three test projects as well for each system. This seems like a cleaner approach. What would be the best way to structure the solution/projects/code to create two versions of a similar system? Let's say I later want to create a third system called `Extreme`, largely based on the `Advanced` system. Do I then create an `AdvancedCore` project which both `Advanced` and `Extreme` extend using partial classes? Is there a better way to do this? If it matters, this is likely to be a C#/MVC system but I'd be happy to do this in any language/framework that is suitable.


title: Do I lose anything by coding in c# and using free online vb.net code convertors?

text: The company I work for uses vb.net since there are many programmers who moved up from vb6 to vb.net. Basically more vb.net resources in the company for support/maintenance vs c#. I am a c# coder and was wondering if I could just continue coding in c# and just use the many online free c# to vb.net code convertors. That way, I will be more productive and also be more marketable since there are more c# jobs compared to vb.net jobs. I have done vb6 many years ago and I am comfortable debugging vb.net code. It's just the primary coding language. I am more comfortable in c#. Will I lose anything if I use this approach. (code conversion). Based on what i read online the future of vb.net is really "Dim". Please advise. thank you


title: Why Browsers do not resolve simple known issues?

text: Why Browsers do not resolve simple known issues such as: (in the context of CSS) Do NOT start a class name with a number! This is only supported in Internet Explorer and Do NOT start an ID name with a number! It will not work in Mozilla/Firefox.


title: Is it necessary to discuss database changes

text: I am working on a project with a team of 4-5 people. Is it necessary to discuss the database changes with the team before implementing? I am working on the database api's. Is it better to discuss this or not? In my team are senior people. So can't I make changes myself and implement the change and explain the changes.


title: Is it normal for a software developer to have lots of issues after product went live?

text: In recent months, our product (which went live probably 9 months ago) experience an increase in the number of users using it. We faced lots of queries, problems, and complaints from users. Sadly, it seems that a lot of the issues seem to be coming from a module that I have been working on. At times, I wonder if I am incompetent, or is this pretty normal in software development, that bugs are found especially during the initial stages of a software development livecycle after it goes live? I wonder why some issues we faced now are not foreseen by me or the team during development phase. I have been working as a software developer for close to 2 years now. Hope to get your opinions, feedback, advices! Thanks!


title: Managing Personal Projects As Solo Developer - Getting out of depth and failing projects

text: I need some advice on project management. I start a project, and often times it will a large project for a solo developer. Usually its a web project. I handle everything from the UI, to the JS, PHP, server management etc. Half way in I feel out of my depth. I lose where I am, so I spend a couple of days away from the project to avoid the stress and before you know it, it becomes another unfinished project. I try to use frameworks and code libraries to make my developments easier on myself. Sometimes I will complete a project so it "works" and then go back and handle errors, design the UI properly and stuff. But without fail I will always end up out of my depth. I've though about outsourcing tasks such as the UI, and the behaviour, and focusing just on the PHP - which I feel is my strong point. But then pride kicks in, and I don't feel at one with a project I haven't completed myself. Does this make sense? I am sure there are many others who have felt like this either at home, or at work, and I would love some advice on managing my projects better.


title: Static class vs Singleton class in C#

text: > **Possible Duplicate:**   >  What is the difference between all-static-methods and applying a singleton > pattern? I need to make a decision for a project I'm working of whether to use static or singleton. After reading an article like this I am inclined to use singleton. What is better to use static class or singleton? Edit 1 : Client Server Desktop Application. Please provide code oriented solutions.


title: Could a singleton type replace static methods and classes?

text: > **Possible Duplicate:**   >  What is the difference between all-static-methods and applying a singleton > pattern? In C# Static methods has long served a purpose allowing us to call them without instantiating classes. Only in later year have we became more aware of the problems of using static methods and classes.   * They can’t use interfaces   * They can’t use inheritance    * They are hard to test because you can’t make mocks and stubs Is there a better way ? Obviously we need to be able to access library methods without instantiated classes all the time otherwise our code would become pretty cluttered One possibly solution is to use a new keyword for an old concept: _the singleton_. Singleton’s are global instances of a class, since they are instances we can use them as we would normal classes. In order to make their use nice and practical we'd need some syntactic sugar however Say that the Math class would be of type singleton instead of an actual class. The actual class containing all the default methods for the Math singleton is DefaultMath, which implements the interface IMath. The singleton would be declared as               singleton Math : IMath     {        public Math        {           this = new DefaultMath();        }     }      If we wanted to substitute our own class for all math operations we could make a new class _MyMath_ that inherits _DefaultMath_ , or we could just inherit from the interface IMath and create a whole new Class. To make our class the active Math class, you'd do a simple assignment               Math =  new MyMath();      and voilá! the next time we call Math.Floor it will call your method. Note that for a normal singleton we'd have to write something like Math.Instance.Floor but the compiler eliminates the need for the Instance property Another idea would be to be able to define a singletons as Lazy so they get instantiated only when they're first called, like               lazy singleton Math : IMath      What do you think, would it have been a better solution that static methods and classes? Is there any problems with this approach? **Addendum** Some points have been raised, that one of the main benefits of static methods is having methods that are "stateless" and thus side-effect free to some extent from a concurrency point of view. I wholeheartedly agree that that's a valid point. However we're mixing two different issues and problems here: One is making some methods invokable and globally accessible without having to explicitly create an instance. The other is having methods that are stateless. The second problem could be solved by method having something like a stateless keyword that similarily to static prevented them from calling this or perhaps do even more to enforce no side-effecs. With singletons rather than static classes and something like stateless classes and methods I think you'd have the following pro's and con's **Pro's**   * "Static" methods in other classes and framework classes could easily be designed to be overridable   * Classes would be easier to test   * Using instances instead of static classes means design patterns work better (things like factories)   * No limitation on inheritance and polymorphism in contrast to static  **Cons**   * Perhaps slightly worse performance?   * Bad programmers will but everything in singletons to have them globally accessible instead of using dependency injection, perhaps you should only be able to access singleton methods and not properties/fields to avoid global variables :)   * ? Perhaps Math was a bad example, but imagine if the .Net string methods were inefficient, you could easily replace them with your own using this method. Or some third-party class has has a singleton method that you wanted to alter slightly, you could inherit and alter that method


title: Patterns to avoid long switch block in UI?

text: Sometimes you have many entities which have common parts, but also should be addressed uniquely in UI. For example, in a CMS, you have many content types (like news, images, articles, pages, etc.) which have title, URL, SEO settings, etc. in common, but which also have specific fields. For example, image have a path field, while news doesn't have that. Now when you want to work with these items per page, you encounter long `switch` and `if` blocks. For example:               switch(currentLoadedContentType)     {        case ContentType.Gallery:            // Show gallery specific fields;            break;        case ContentType.News:            // Show news specific fields;            break;        case ContentType.Artiel:            // Show artiels specific fields;            break;        case ContentType.Page:            // Show pages specific fields;            break;     }      As you increase the number of content types, this lists gets longer and longer. What patterns are available to reduce the length or eliminate this long switch, but at the same time don't result in repetition. (I'm a big fan of DRY).


title: Difference between hash and dictionary

text: What is the difference between Hash and Dictionary. Coming from a scripting background, I feel that they are similar , but wanted to find out the exact differences, Googling did not help me much.


title: Programming a trading strategy

text: Excuse me if I'm not descriptive enough, as I do not have much of a background when it comes to these things: How would I go about coding a primitive trading strategy and link it to some sort of artificial trading environment? Where do I start, and what are some other essential questions I should be asking? I am interested more in doing this because it interests me than making returns. Ideally it utilizes random/historical market data and doesn't actually execute any real trades. My background: I'm almost done my undergrad degree in computer science, and have had intro finance and economic courses. Familiar mostly with C and Java.


title: Is anyone doing "real" TDD with Visual-C++, and if yes, how do they do it?

text: Test Driven Development implies _writing the test before the code_ and following a certain cycle:   * Write Test   * Check Test (run)   * Write Production Code   * Check Test (run)   * Clean up Production Code   * Check test (run) As far as I'm concerned, this is only possible if your development solution allows you to very quickly switch between the production and test code, and to execute the test for a certain production code part extremely quickly. Now, while there exist lots of Unit Testing Frameworks for C++ (I'm using Bost.Test atm.) it does seem that there _doesn't_ really exist any decent (for _native C++_ ) Visual Studio (Plugin) solution that makes the TDD cycle bearable regardless of framework used. "Bearable" means that it's a one-click action to run a test for a certain cpp file without having to manually set up a separate testing project etc. "Bearable" also means that a simple test starts (linking!) and runs very quickly. So, what tools (plugins) and techniques are out there that make the TDD cycle possible for native C++ development with Visual Studio? Note: I'm fine with free or "commercial" tools. **Please** : **No** framework recommendations. (Unless the framework has a dedicated Visual Studio plugin and you want to recommend the plugin.) * * * Edit **Note** : The answers so far have provided links on how to integrate a Unit Testing framework into Visual Studio. The resources more or less describe how to get the UT framework to compile and get your first Tests running. _This is **not** what this question is about._ I'm of the opinion that to really work productively, having the Unit Tests in a manually maintained(!), separate vcproj from your production classes will add so much overhead that TDD "isn't possible". As far as I am aware, you do _not_ add extra "projects" to a Java or C# thing to enable Unit Tests and TDD, and for a good reason. This _should_ be possible with C++ given the right tools, but it seems (this question is about) that there are very little tools for TDD/C++/VS. * * * Googling around, I've found one tool, VisualAssert, that seems to aim in the right direction. However, afaiks, it doesn't seem to be in widespread use (compared to CppUnit, Boost.Test etc.). * * * Edit: I would like to add a comment to the context for this question. I think it does a good summary of outlining (part of) the problem: (comment by Billy ONeal) > Visual Studio does not use "build scripts" that are reasonably editable by > the user. One project produces one binary. Moreover, Java has the property > that Java never builds a complete binary -- the binary you build is just a > ZIP of the class files. Therefore it's possible to compile separately then > JAR together manually (using e.g. 7z). C++ and C# both actually link their > binaries, so generally speaking you can't write a script like that. The > closest you can get is to compile everything separately and then do two > linkings (one for production, one for testing).


title: Is this an acceptable approach to undo/redo in Python?

text: I'm making an application (wxPython) to process some data from Excel documents. I want the user to be able to undo and redo actions, even gigantic actions like processing the contents of 10 000 cells simultaneously. I Googled the topic, and all the solutions I could find involves a lot of black magic or is overly complicated. Here is how I imagine my simple undo/redo scheme. I write two classes - one called `ActionStack` and an abstract one called `Action`. Every "undoable" operation must be a subclass of `Action` and define the methods `do` and `undo`. The `Action` subclass is passed the instance of the "document", or data model, and is responsible for committing the operation and remembering how to undo the change. Now, every document is associated with an instance of the `ActionStack`. The `ActionStack` maintains a stack of actions (surprise!). Every time actions are undone and new actions are performed, all undone actions are removed for ever. The `ActionStack` will also automatically remove the oldest `Action` when the stack reaches the configurable maximum amount. I imagine the workflow would produce code looking something like this:               class TableDocument(object):         def __init__(self, table):             self.table = table             self.action_stack = ActionStack(history_limit=50)              # ...              def delete_cells(self, cells):             self.action_stack.push(                 DeleteAction(self, cells)             )              def add_column(self, index, name=''):             self.action_stack.push(                 AddColumnAction(self, index, name)             )              # ...              def undo(self, count=1):             self.action_stack.undo(count)              def redo(self, count=1):             self.action_stack.redo(count)      Given that none of the methods I've found are this simple, I thought I'd get the experts' opinion before I go ahead with this plan. More specifically, what I'm wondering about is - are there any glaring holes in this plan that I'm not seeing?


title: Application Logic – which of the two definitions is correct?

text: This is my understanding of the _Application Layer_ : • It implements _Application logic_ • this layer contains _Application Services_ , which are used by external consumers to talk to your application • _Application Services_ are coarse-grained and orchestrate operations which map directly to _use cases_ ( hence also the term _Workflow Services_ ) 1)   From: > Application Logic is mostly workflow logic. It is the application specific > coordination of domain and infrastructure components according to the > requirements of that particular application. From: > Let's start a company, shall we? Sapient Grey will be primarily a think > tank, but with an in-house development group with the capabilities to make > the visions of the core committee a reality. Our corporate motto, "Sapient > Grey is People..." will be burnished in giant brazen letters alongside a > customized version of Rodin's famous sculpture "The Thinker", all of which > will adorn the east-facing side of our brand new ten story red granite > office building.... Oh, wait. We don't have an office building yet. Okay > then, so we'll hire an architect to design our office building, being sure > to include a private elevator and an elaborate zen-style atrium or courtyard > in the center. In the meantime, while the building is being designed and > constructed, you and I and our other elite colleagues will fly ourselves to > Tahiti to brainstorm Sapient Grey's visions, goals, agenda, and lay out a > detailed business plan. > > Our architect is creating detailed blueprints for the office building, > figuring out how the plumbing will need to be laid out, how the electrical > systems will be segregated and tied together, how the interoffice > communication system will be organized, and how we will implement security > at all levels. The systems and designs that our building architect is > handling is a precise analogy to what "Application Logic" is within a web > application. How security is implemented, how we will manage and access > state and persistence, how we will handle storage and retrieval of > data....this is application logic. Like our office building, which when > complete could house and accommodate anything from an elite night club to an > investment firm, the application logic is independent of the actual business > logic that executes within it. a) The above quotes are two different definitions of the term _Application Logic_ and as such it appears they just happen to use the same term (ie _Application logic_ ) to describe two different concepts. Thus, does only the the first definition describe the logic contained in _Application layer_ , while the latter definition is describing a different kind of logic? b) If indeed both definitions describe the logic in _Application layer_ , then wouldn't this mean that _Application layer_ performs two tasks: orchestrating operations that map directly to _use cases_ and executing non-business related logic (such as security, caching etc)?


title: Modelling Betting Markets

text: I've got some general questions about modelling a series of betting markets and bets within them. I'm writing in Ruby but it's ultimately agnostic towards which language I want to use. I have a concept of "games", for example, a soccer league. While the league is running, people can place various types of bets. A bet might be the winner of the league, or it might be the top three winners in any order. Or the top three winners in order. This is called a "market". Within a game I also have participants. These are the teams that make up the league. A bet consists of one or multiple participants, the order of these participants is important plus an amount. It is stored against the market. My question is how should I got about organising this? At the moment I have market types (say Win) inheriting off a base market class. The base class I'm using looks like this:               class Base         def self.make(game, market_name)             puts Kernel.const_get("MatchMaker::Markets::#{market_name}")         end     end      The make function is a factory method for generating win classes based on a string passed in with the name off the bet type. This generation seems a bit clunky at the moment, and I'm somewhat concerned that it might cause me further problems down the track. I realise this question is somewhat rambling and doesn't have a clear answer. I'm interested more in other peoples ideas in how they would go about putting something like this together.


title: Designing a Web Application with Two Different Backend Databases

text: I'm working on a pretty standard LAMP based web application. The server itself has a standard MySQL database and the application is written in PHP. The kicker is, we also use SQL Server databases with this application. ## The current data setup is this:   * MySQL stores the user account information (Username, password, privileges, etc.) and a "connection identifier".   * The connection identifier links to another table that stores connection credentials for a SQL server database.   * When a user logs in, a connection is made to a remote SQL Server database (these are hosted independently of the web application and not in my control).   * Using that connection, the web application processes and outputs the data (only reads, no writes). The application has evolved greatly and, while the organization and practices have improved, the design is still pretty messy and confusing. I struggle to implement any kind of framework or ORM because most are designed with one database in mind. I have stitched together a framework that works very well for reports (where only the SQL Server connection is needed) but it doesn't go well with things like account interaction (where SQL server is used for validation of data that goes into MySQL). The setup doesn't look like it will change so I was wondering if there was any advice on designing and maintaining a web application with two different database backends at the same time. On a side note, storing the credentials for remote SQL Server databases on our MySQL database makes me nervous. I can only encrypt the passwords as I need them for connections and, as it currently stands, all the accounts used are admin accounts with full privileges. Not something you want getting out especially when these databases are opened up for internet connections. So any advice for that would be nice as well.


title: Choosing value in SQL query vs (Java) code

text: I need to choose one of three values of an integer using the value of a column on a nullable column of a table. There are at least two approaches: 1) use SQL to do all the work: test null values, and choose between the other values, or 2) read the value and use code -in this case Java- to choose. Which one is "better", ie. easier to understand & more maintainable? Do you have any other metric use to decide? As an example, I have the following code:               // If id is equal to:     //   -1, then make v = 1     //   null, then make v = 2     //   in any other case, make v = 3          // Option 1:     int v;     String query = "SELECT CASE min(Id) WHEN NULL THEN 2 WHEN -1 THEN 1 ELSE 3 END AS Id"             + "FROM TableA WHERE SomeField IN (SELECT ...blah blah...)";     ResultSet rs = // execute query     if (rs.next()) {         v = rs.getInt("Id");     } else {         // TODO something went *very* wrong...     }          // Option 2:     int v;     String query = "SELECT CASE min(Id) Id"             + "FROM TableA WHERE SomeField IN (SELECT ...blah blah...)";     ResultSet rs = // execute query     if (rs.next()) {         final int id = rs.getInt("Id");         if (rs.wasNull()) {             v = 2;         } else if (id == -1) {             v = 1;         } else {             v = 3;         }     } else {         // TODO something went *very* wrong...     }


title: How to provide a custom ID to a downloadable application?

text: I've noticed that with remote support services, a technician usually sends you a download link to an executable. When you click on that link, it installs a software which automatically connects with the remote technician and allows him/her to access your computer. Basically, what's happening is that somehow the installed application has a session ID which it's using to identify and connect with the technician. How is that session ID passed onto the downloaded application? Is a custom executable compiled/generated for each session and the executable has that session ID embedded within it's resources? any other method of achieving the same?


title: GPLv3 code in non-GPL software -- linking vs. CLI

text: Suppose there's a GPLv3 app that has a GUI and a CLI. Can I legally expand its CLI (to give me access to functionality hitherto only available via the app's API), release the result under GPL and then create a non-GPL (perhaps proprietary) app that depends on this modified GPL app (via the expanded CLI)?


title: Deprecate a web API: Best Practices?

text: Eventually you need to depreciate parts of your public web API. However I'm confused on what would be the best way to do it. If you have a large 3rd party app base just yanking old versions of the API seems like the wrong way to do it as almost all apps would fail overnight. However you can't keep ancient web api's available forever as it might be outdated or there are significant changes that make working with it impossible. What are some best practices for deprecating old web api's?


title: Task Consumer/Processor architecture

text: **PROBLEM** We have various tasks in our system which can take up to 20 minutes. These tasks are generally started from the web interface and run on a new thread. This is obviously a terrible solution because the task could be recycled by IIS and it hogs up precious resources on the web server. **POSSIBLE SOLUTION** Hosting a `TaskConsumer` class in a windows service (or Azure Worker Role, in our case), which picks up tasks and processes them. This would handle the queuing and running of tasks. New tasks are added to a database table (say `Tasks`) in the client code via some `TaskManager` class (`TaskManager.Enqueue(ITaskable)`), which are then picked up by the `TaskConsumer` (perhaps it is polling this table for additions?). This table would also be updated by the `TaskConsumer` while the task is executing (perhaps a state field - `RUNNING`, `QUEUED`, `FAILED`, `COMPLETE`). To create a new type of task, one would implement an `ITaskable` interface. This would demand implementations for a `Process()` method, which would contains the logic to run that task. A UI interface could show all active tasks and perhaps provide some management capabilities (e.g. cancel a task, restart a task, etc). This info can be retrieved from the `TaskManager` class (`TaskManager.ActiveTasks`), which essentially is reading from the `Task` database table. The `ITaskable` concrete implementations would need to have serializable properties so to be stored in the database. This is neede because there would be specific parameters/data needed to run the task. For example, an `ImportEmployees` task would need to have the name of the file which was originally uploaded. This would need to be known at the time the consumer needs to execute the task (on desialization). ![Architecture](http://i.stack.imgur.com/HSTYi.png) **Is this a good approach to tackle this problem?** I am sure there must be many patterns out there for this kind of problem.


title: Attributes of an Ethical Programmer?

text: Software that we write has ramifications in the real world. If not, it wouldn't be very useful. Thus, it has the potential to sweep across the world faster than a deadly manmade virus or to affect society every bit as much as genetic manipulation. Maybe we can't see how right now, but in the future our code will have ever-greater potential for harm or good. Of course, there's the issue of hacking. That's clearly a crime. Or is it that clear? Isn't hacking acceptable for our government in the event of national security? What about for other governments? Cases of life-and-death emergency? Tracking down deadbeat parents? Screening the genetic profile of job candidates? Where is the line drawn? Who decides? Do programmers have responsibility for how their code is used? What if a programmer writes code to pry into confidential information or copy-protected material? Does he bear responsibility along with the person who used the program? What about a programmer who knowingly or unknowingly writes code to "fix the books?" Should he be liable?


title: What are the pros and cons of Coffeescript?

text: Of course one big pro is the amount of syntactic sugar leading to shorter code in a lot of cases. On http://jashkenas.github.com/coffee-script/ there are impressive examples. On the other hand I have doubts that these examples represent code of complex real world applications. In my code for instance I never add functions to bare objects but rather to their prototypes. Moreover the prototype feature is hidden from the user, suggesting classical OOP rather than idiomatic Javascript. The array comprehension example would look in my code probably like this:               cubes = $.map(list, math.cube); // which is 8 characters less using jQuery...


title: How to gain Professional Experience in Java/Java EE Development

text: I have been seeing opportunities go past me for just 1 reason: not having professional industry experience. I say to many employers that I'm capable of doing the job and show them the work I've done during the academics and also several personal projects which I took extra time and effort to teach myself the new industry standard technologies. But still, all they want is some 2-3 years experience in an industry. I'm a recent graduate with a Master's Degree in Computer science. I've been applying for quite a few jobs and most of these jobs require 2 years minimum experience. So, I thought somebody here might give me some realistic ideas about getting some experience which can be considered professional. Any kind of constructive comments are welcome.


title: Application that provides unique keys to multiple processes

text: Any idea on how to build an application that provides unique keys each time it get called by another process.   Calling process isn't my problem here, my problem is how to sync between two(or more) processes and preventing it from providing the same key to both of them. I'd really appreciate your help in this issue, please only outline the solution and I'll try to implement it.


title: Do we need to adopt a black-box asset our project is inheriting from its predecessor?

text: Our client has an eCommerce site which was developed by an in-house team, and is now showing its age. I work for a firm brought in as external contractors to build a replacement. Part of the current site is a Flash viewer applet which displays media about the product - zoom-able images, 360-degree views, movies, and so on. We need to show the same media the current site does, so we are simply reusing the viewer. The viewer is embedded on a page in the usual way, and told what media to show by means of an XML file it loads from our server, which is pretty simple for us to generate. We've got this working; it was pretty straightforward. But what else do we need to do? The thing is, as far as we're concerned, the viewer is a binary blob which is served from the client's content-distribution network. We embed it, feed it some XML, and it does its job, but we have no power over its internals. It's completely opaque to us - a black box. We can use it to do what it does, but we can't change it, so if we ever need to do something different, we're stuffed. We're building this site for the client, and when we're done, we'll hand it over for them to maintain. We won't be doing the maintenance ourselves. There's a small team within the client who are working as part of our team, and who will be the ones doing the maintenance. That team only includes one person from the team that built the old site, and it's not someone who knows the image viewer. The people who do know the image viewer are not slated to join our team when our system replaces theirs - they'll be moved to other projects. The documentation on the viewer is extremely thin, and as far as i know doesn't cover the internals at all. My worry is that if someone doesn't take some positive action, all knowledge of the internal workings of the viewer - even down to where the source code for it is - will be lost. It's possible it already has been. Is this something to worry about? If so, whose job is it to worry about it? What should they do about it once they've got worried?


title: The most mind-bending programming language?

text: From a _reasonably_ common programming language, which do you find to be the most mind-bending? I have been listening to a lot of programming podcasts and taking some time to learn some new languages that are being considered upcoming, and important. I'm not necessarily talking about BrainFuck, but which language would you consider to be one that challenges the common programming paradigms? For me, I did some functional and logic (for example, Prolog) programming in the 1990s, so I can't say that I find anything special there. I am _far_ from being an expert in it, but even today the most mind-bending programming language for me is Perl. Not because _"Hello World"_ is hard to implement, but rather there is so much lexical flexibility that some of the hardest solutions can be decomposed so poetically that I have to walk outside away from my terminal to clear my head. I'm not saying I'd likely sell a commercial software implementation, just that there is a distinct reason Perl is so (in)famous. Just look at the basic list of books on it. So, **what is your mind-bending language that promotes your better programming and practices**?


title: Pattern for costly precondition check before acting

text: Let's say I have a method `DoTheThing()` which requires the precondition-check `CanTheThingBeDone()` to return true. The latter method is time consuming as it accesses the database. I'm finding it hard to find a perfect way to perform the precondition check effectively (i.e. _once_ ) while maintaining both readability and API integrity. Observe these examples: **Example 1:**               class System() {         public void DoTheThing() {             if (!CanTheThingBeDone()) throw new Exception(...);             // Do it         }              public bool CanTheThingBeDone() {             // Some time consuming code         }     }          class Consumer() {         public void SomeLargerOperation() {             try {                   system.DoTheThing();             }              catch (Exception) {                  // Error handling             }         }     }      **Example 2:**               class System() {         public void DoTheThing() {             // Do it         }              public bool CanTheThingBeDone() {             // Some time consuming code         }     }          class Consumer() {         public void SomeLargerOperation() {             if (system.CanTheThingBeDone()) {                  system.DoIt();             }         }     }      Both approaches are ok, but both have drawbacks. In _Example 1_ , I'm forcing the consumer to wrap the code in a try-catch for faulty states. These states can be user-triggered so some graceful handling is required. I'm unsure if try-catch for handling user-errors is a good approach. In _Example 2_ I'm handing the responsibility of state-checking over to the consumer, opening up for non-descriptive runtime errors. In _this_ example, CanTheThingBeDone() is checked, but when Jimmy enters the team 1 year from now to develop module 2, that might change. **Example 3:**               class System() {         public bool DoTheThing() {             if (!CanTheThingBeDone()) return false;             // Do it              return true;         }              public bool CanTheThingBeDone() {             // Some time consuming code         }     }          class Consumer() {         public void SomeLargerOperation() {             if (!system.DoTheThing()) ProduceSomeErrorMessage();         }     }      Now in this example, I avoid try-catch for user errors and prevent the actual Do-code to be executed if invalid state, while ensuring the check-code is run only once. But I feel I'm breaking some naming/coding principle when the method is both performing check and modifying class state (I'm pretty sure it even has a name). As a fourth example, I could envision a combination of #1 & #2 where both the consumer and `DoTheThing` calls `CanTheThingBeDone`, but then we're doing the work twice. To sum up - I can't seem to find a best approach. Anyone have a better idea than mine, or suggestions on how to tweak one of these approaches for a better result?


title: Fail-fast paradigm overheads

text: Fail-fast seems like a right way since it simplifies bug detection. But it's a harm for performance cause of multiple checking the same thing at several levels of the system. Simple example. There is a function that input parameters must be not null. And there is function wrapping it, that also await the same parameters also not null. After some activities function-wrapper passes input parameters into first one. So that the same items checked two times: at the beginning of function wrapper and inside wrapped function. So I would like to know how much widespread this style is. Should I write fail-fast code or check everything just once?


title: Commit projects individually or whole solution?

text: I am working (alone) on an application that is a music portal where you can search for artists, songs etc ... The C# solution consists of:   * a class library that contains all the stuff to access the web service   * the application itself I've recently started using Git and figured out the benefits it does provide to a project but there's something I couldn't figure out, on Visual Studio there is the option to commit a solution which leads me to the following question : Should I commit each project individually or the whole solution ?


title: What is an Anti-Corruption layer, and how is it used?

text: I'm trying to figure out what the Anti-Corruption layer really means. I know that it's a way to transition/work around legacy code or bad APIs. What I don't understand is how it works and what makes it a clean separation from the undesirable layer. I've done some searching, but I can't find any simple examples or explanations, so I'm looking for someone who understands it and can explain it with simple examples. An answer that would satisfy my question should be simple (not necessarily short), and provide understandable examples of implementation and use. See this question, for my use case.


title: C# Logic - gaps & Islands

text: I am looking for help designing the display of available times for appointments (for example a hairdresser's appointment book). Currently I have a query that returns a collection of periods that are unavailable for appointments (whether there is an existing appointment or if the service provider is closed). So lets say Feb 3rd, from 12 to 5 is unavailable, i want to output the following string: Jan 1st 12 am - Feb 3rd 12pm Feb 3rd, 5pm - Dec 31 12 am. My entire range is 1 year from Jan 1st to December 31st and there can be as many unavailable dates.


title: Multiple Dispatch and CLOS

text: I have never written software in Common Lisp, but in Scheme and Clojure as well as C++ and Python. Yet I have had a look at the Common Lisp Object System (CLOS) in Common Lisp and Dylan. Now when comparing it to OOP in the Simula tradition, CLOS and lets say C++ and Python class system have polymorphism as a common trait. They seem to differ in the way how data and methods are organized, in the Simula family, methods are an integral part of classes, sub-items if you will while with CLOS they are defined outside of classes and are rather generalized procedures. Common Lisp proponents typically argue that virtual methods in Simula-family programming languages are quite limited since they are invoked only according to the first-argument object (`this` or `self`). CLOS generic functions are selected for several arguments, thus something like (pseudo code)               method draw(c : Device, d : Drawable) ...       can be implemented for arbitrary `Canvas` and `Drawable` combinations.               method draw(c : Printer, t : Triangle)....     method draw(c : Printer, t : Image)....     method draw(c : Screen, t : Image) ....      In Simula-family languages, this would be more difficult, since `draw` would have to be associated with either the `Device` or the `Drawable` family of objects. The canonical solution seems to be the Visitor Pattern http://en.wikipedia.org/wiki/Visitor_Pattern . Upon learning CLOS, I was quite amazed that most OO programming languages do not offer multiple dispatch - and - wondered if there are specific reasons, why one might associate methods so closely with one specific class. **Are there specific advantages for single dispatch?**   * ambiguity of multiple dispatch: i.e. lets say I have `a` subclassing `A` and `b` subclassing `B`. The method `foo(A,B)` implemented as `foo(a,B)` and `foo(A,b)`, which implementation would a call of `foo(a,b)` invoke? Is this the only reason?   * "Modularizing", methods in the class are near. Is there more to it? Have language designers and creators taken a stance on this matter?


title: How best to look up objects by label?

text: I am writing the server backed by a pre-written API. I'm going to get a number of strings representing ports, signals, paths, etc etc etc. I need to look up the object associated with a given label, these objects are all in memory (no sql magic to do this for me). My question is, how best do I associate a given unique label with the mutable object it represents? I have enough objects that looking through every signal or every port to find the one that matches is possible, but may be slightly too slow. To be honest the direct 'look at every object' method is probably good enough for so small a body of objects and anything else is premature optimization, but I still am curious what the proper solution would be if I thought my signals were going to grow a bit larger. As I see it there are two options available. First would be to to create a 'store' that is a simple map between object and label. I could have it so that every time I call `addObject` the object is automatically saved into a hashmap or the like. This works, but relies on my properly adding _and deleting_ each object so the map doesn't grow indefinitely. The biggest issue to me is that this involves having some hidden static map in my ModelObject class that just feels...wrong somehow. The other option is to have some method that can interpret the labels. All of these labels are derived from the underlying objects. So I can look at the signal label, for instance, and say "these 20 characters are the port" to figure out what port I need. This would allow me to quickly figure out what I need. However, if the label method is changed the `translateLabelToObject` method needs to be updated as well or everything breaks. Which solution is cleaner, or possibly a cleaner solution than either of above? For the record I'm working with sufficient number of variables to make direct comparison a little slow, but not enough to be concerned about memory overhead, written in java. All objects that have labels I need to look up extend the same parent class.


title: How can I find contract Android work?

text: Two years ago, following 15+ years in Win32 and SymbianOS, I decided to intensively focus on Android. I took the best part of 2009 off work to learn the new platform thoroughly, and that seems to have been a good strategic decision: Android is everywhere now. But it seems strangely hard to find Android development work. I have this nagging feeling that there must be some website, some secret society or labour exchange, that has somehow eluded me. What's going on? If you're an Android contractor, how did you find your current work?


title: Is it possible to know what programming language a web-site uses?

text: For example, `stackexchange.com`, without asking the site owner or Google their information about developing the website, is this possible to know what language is used in the back end? Seems, the website don't have `.extension` bar, for example `.php` that can indicated which is developed in `PHP`, but without the extension, how can I know that?


title: Are super methods in JavaScript limited to functional inheritance, as per Crockford's book?

text: In Douglas Crockford's "JavaScript: The Good Parts", he walks through three types of inheritance: classical, prototypal, and functional. In the part on functional inheritance he writes: > "The functional pattern also gives us a way to deal with super methods." He then goes on to implement a method named "superior" on all Objects. However, in the way he uses the superior method, it just looks like he is copying the method on the super object for later use:               // crockford's code:     var coolcat = function(spec) {         var that = cat(spec),             super_get_name = that.superior('get_name');         that.get_name = function (n) {             return 'like ' + super_get_name() + ' baby';         };         return that;     };      The original `get_name` method is copied to `super_get_name`. I don't get what's so special about functional inheritance that makes this possible. Can't you do this with classical or prototypal inheritance? What's the difference between the code above and the code below:               var CoolCat = function(name) {         this.name = name;     }          CoolCat.prototype = new Cat();          CoolCat.prototype.super_get_name = CoolCat.prototype.get_name;     CoolCat.prototype.get_name = function (n) {         return 'like ' + this.super_get_name() + ' baby';     };      Doesn't this second example provide access to "super methods" too?


title: Load testing : how to generate per second requests?

text: I have a server component which runs over Zeroc-ICE. When I wanted to load test it, I thought that using parallel library to create multiple requests would do it. But it dint end up that way. **Using Parallel(Parallel.For)** library from C# apparently was easier but it doesn't seem to be exactly generating everything parallel in the same instant. So it cannot be the definition for creating N requests per second. How should I do it ? I guess anyone who wants to do load testing first would actually think about this .   1. What's the efficient way to actually create N requests in really per second ?    2. Another myth is about the parallel programming. Please enlighten us , if you have used parallel programming patterns in C# or .Net in general . Imagine I have 5 processes. How will start all the five processes at the same time. What does it mean to my consumption of resources ? I have tried reading into many of the material available over the net but I get more and more questions than them being the answer to my questions.   3. I used Parallel.For and created N threads and measured time. Then I tried the same thing using Task.Factory.start for enumeration of tasks. The time measured was different. So What exactly is the different between using these ? When I should use the corresponding classes and for what purposes exactly ? we often have lots of riches but its just we exactly don't know how to differentiate one from the another. This is one such case for me, not being able to find why I should not use one from the another.   4. I used the stopwatch class to measure these times which claims to be the best. In the scenario of me load testing a component, what would be the way to measure the time of response. Stopwatch seems to be the best solution for me . Any opinions are welcome. ps: There are many load testing tools for web applications. Mine is a customised case of server components. And my question is more pertaining to creating N threads per second. **All opinions are welcome. Just don't think its so much not a programming question. It ofcourse is. It should ring bells for any programmer who wants to QE stuff by himself to know the performance of his product , first hand by himself.I have tried many options and then had to fall back on how should I actually do it ?**


title: What is 'code skew'?

text: In the O'Reilly book on Scala, I read that copy-pasting of code creates: > ... creates issues of code-bloat, maintainability and _skew_ , I can't see any obvious definitions of the word skew in context. I am aware of the problems of copy-pasting, but I can't make them fit with the word 'skew'. Since this is used in an O'Reilly book I'm guessing it's a real programming term in circulation. Any pointers?


title: Developed a web site - How to explain in an interview

text: I developed a e-commerce site for a major company. I did not create some kind of a document to show how the data flows between pages. I used: PHP, HTML, CSS, JavaScript, ExpressionEngine, plugins Modules and some other web technologies When I go to an interview I want to show my site and explain how it works and how I developed the site. Usually I go page by page and explain how the site works. Is there a nice creative way to explain how the site works?


title: Handle invalid text on server or fix on client in Client-Server application

text: I have developed a protocol for a Client-Server application and developed it in conjunction with another developer. The client application at this moment is written for the mobile phone. The protocol uses comma separated fields with start and end deliminators. Because some of our fields are free form ASCII text we are byte stuffing the fields so that special characters can be handled within and not mess up our data parsing. The problem is that one field has been byte stuffed when it shouldn't have been. The field in question was to represent coordinates i.e.                   <rest of data packet>, <lat>,<lng>,....          where      <lat>:   Latitude coordiantes i.e. -37.6543     <lng>:   Longtitude i.e. 90.8993      However what we I recieved on the server was the byte stuffed character for a comma appearing in the **dot** field i.e. **-37^-6543.** This in turn caused the server to ignore the packet and not record the details. **Reason** : When I mentioned this to the phone developer he said it was because the character settings on the phone meant that the user had changed the dot to a comma. It was his belief that we should handle this on the server. However I'm not sure. I have a thought that clients should follow the protocol as in theory there could be different clients connecting and the server doesn't want to have special cases littered in it's code base? **Question** : So some options I see are (and I'm not sure how to approach this):   1. Get all clients to send the data as per for the protocol spec and keep the data format black and white so to speak   2. Have the server handle a variety of options in this case   3. In conjunction with 2 adjust the protocol document so that data is more flexible in some cases and the server is responsible for handling the different cases


title: During software development, which development phase matters most to the programmer?

text: What does a programmer need to pay attention to during the development of software? For example, some software can not be finished within the time constraints, others cannot meet the requirements of clients.


title: Software license for commercial/free software

text: I am building software in PHP right now which will be released with a free version and several premium versions. I'd like a license which allows people to freely modify the code, but not to redistribute it, or include it in proprietary software or any other software without a license. Would the MIT license be best?


title: Use Queue<T> or stick to native f# lists

text: I need something that represents a queue in F#. The queue will be filled with items once, and (as the application progresses) items will be taken from this queue and moved to other lists. Should I use the Queue class in .NET, or should I avoid it, and use the native lists in F# instead? Is there a better solution? Why should I use one, or the other, in a functional language such as F#?


title: How to test the same software on all products in a product line?

text: In my team we have been working on a firmware for a product. The product was released some years ago but we still implement new features in the firmware and regularly provide a new firmware for our customers. Recently we have developed a new product which use the same firmware as the first one. Of course, we had to change the firmware to allow for some new capabilities (while still keeping functionality for existing product intact). We have a release test specification which contans mostly manual tests which we carry out before we release any new software. We have adapted this for the new product since it has additional capabilities. But most of it is common. I know that new products are in the pipeline and in my simplistic reasoning we need to repeat our release test for each product every time we release a firmware. So i am looking for a new approach which is less time consuming. One of the things we are already working on is automation, but due to the nature of the product many tests _have_ to be manual.


title: Optimizing web applications

text: What are the things we need to take care for a web application to handle large number of requests(say 10000 simultaneous requests). Increasing the number of servers and distributing the load is one way , but are there other ways or configurations that can be done on application server ?


title: What are the differences between throwaway and evolutionary prototypes?

text: I have notes about various methods of prototyping, and I found several definitions on the Internet, but I would like to confirm what I learned. I understand that **throwaway prototyping** is developed from an outline of a specification, an various prototypes are delivered and modified until the client is satisfied with its functionality. On the other and, **evolutionary prototypes** are built from basic requirements gathered from end-users. An initial prototype is presented to the users and evaluated. The prototype is modified based on the feedback until the client is satisfied. Is this correct? Are there better definitions of throwaway and evolutionary prototyping?


title: Should experimental code be preserved?

text: Am am working on a small project for a USB device firmware. I started from a working example, and am gradually adding new functionality and testing things. However, the new functionality is not all intended to be used in the final project. I am writing it to learn how to do things on this concrete platform, and fixing unexpected problems in the process (for example, on of my test PCs had non-functional USB ports). What should I do with the old code? The code is version controlled, of course. I see two possibilities:   * Change old code into new one. An example here would be, when moving from having a Loopback over the UART (for testing purposes), and moving to more sensible use of the UART, change the DMA code to read not from the input of the UART, but from the CPU buffer, that is to be sent out.   * Use a bunch of `#if` statements to make the source code configurable, so that any version of the code can be compiled by only providing the correct `#define`. If the latter approach is recommended, where is the dividing line? I can't keep _every_ line of code that I write, hiding it behind an `#if`.


title: Constants in C#

text: Why does the compiler store constant values in the assembly metadata? Are they directly embedded to Intermediate Language code from the assembly metadata?


title: Should I Use an ORM only when dealing with Data Model objects?

text: I am new to ORM, and we started developing a new system using NHibernate as the ORM. I think this question may refer to any ORM and any language/platform. The Team Leader has said we should use NHibernate only when retrieving our domain data model objects, ie, not to use any of the built in NHibernate selection or aggregations that will retrieve single primitives or a list of primitives. The reason behind it was that we need to make a distinction between classic ORM and other abilities, so that usual select and select max will use a "classic" DAL project. I think this is not so good, because we break the data access to two, and what's wrong using NHibernate abilities which gets checked compile time? **Are there any reasons to making this distinction?**


title: Recommended reading for (Object Oriented) application design architecture?

text: > **Possible Duplicate:**   >  Best books on the theory and practice of software architecture? In life it doesnt matter if you do one thing for 15 years. You **will** end up waking one day and asking stuff that are equal to "how do i walk?" :) My specific question is that as a new entrant to C# and OOP i am stepping into many little "details" that need to be addressed. Written a lot of code in VB.NET / cobol / simple php e.t.c surely does not help much into the OOP world... So , even after reading entry level books for C# and watching some videos i recently found out about the "factory model design" for applications. I would appreciate if any of you guys recomment some reading on application design architecture for further reading...


title: How to approach the creation of a "Unit Outline" generator?

text: I am the Studies Coordinator at a College and we currently have somewhere in the order of 100-200 unit outlines that are created at the beginning of each semester. Those outlines need to have information like:   1. Unit Name   2. Unit Code   3. Course Type   4. Assessment Item 1 Name   5. Assessment Item 1 Distribution date... And the list goes on and on. All up there are anywhere between 50-150 pieces of data that teachers enter into their outlines depending on the 10-20 different types of outline they might be creating. Currently we have staff entering data into one of many different Word documents with editable fields. This works okay, but every time the outlines need to have a change made, you can imagine the work involved. The outlines also look poor because different table rows move across different pages...it's just messy. We have tried using InfoPath files...maintaining those was a nightmare and the school won't go back to that. I am contemplating a solution where teachers enter the unformatted/raw data into some kind of front-end (I was thinking an Excel file) and then I write a program that sweeps through the data and generates outlines for me. I've been experimenting with simply using Mail Merge but this doesn't give me the flexibility to tailor the end result based on the data coming in (different numbers of Assessment Items for instance) I know how to work with quite a lot of languages and technologies and am willing to use this as a project into something I might be unfamiliar with but I was looking for advice on ways to approach this so that I can streamline the whole Unit Outline process. Any ideas would be much appreciated.


title: How do you normally layout a class's regions?

text: I was wondering if there was a standard for laying out a class's regions. I currently use               Fields     Constructor     Properties     Public Methods     Private Methods      `Fields` being Private Properties and `Properties` being the public ones. I'll normally use subregions within that if needed, or will occasionally add other regions below (such as interface or baseClass members).


title: Why is Web SQL database deprecated?

text: I am making a hybrid Android app. At first I decided to use localStorage, after spending 2 days, I realized that it is very strange and so dropped it. Then, I picked up indexedDB, after spending today's whole day and actually getting the output in Google Chrome, it is not running inside a WebView of the android app. And I never used Web SQL database at all because it was deprecated. Anyhow, it has come to my notice that PhoneGap still uses Web SQL and android's browsers support it. Why was Web SQL deprecated in the first place? And will it be a good idea for me to go with Web SQL now?


title: Why aren't extension methods being used more extensively in .NET BCL?

text: I found the "Extension method" concept of C# just wonderful. It enables us to do things like:   * More flexible alternative to Abstract Classes.   * Provide missing Java-like functionalities to C# `enum`. And The coolest thing about it IMHO is that **adding a method doesn't break backward compatibility**. However, I found almost no extension methods in the .NET BCL. And it's very common that, I see a static method and extension methods come in mind. When the BCL was designed, extension methods were not there. But why are they not converted to extension methods now? Specially when it does break backward compatibility? Any reasons?


title: Scrum: Short VS long sprint

text: We were trying to figure out the optimal sprint length for our project. After working on a 3-weeks basis we thought that cutting the sprint to 2-weeks would provide better velocity. The advantages were clear - shorter feedback loop, small stories (with user value) and so on. On the other hand, there are a lot of disadvantages such as ceremonies (planning, retrospective) and so on in which we don't produce and now happen more often. I was wondering how, for a new team, can we decide on optimal sprint length?


title: Heap overflow vs stack overflow

text: So as a general rule to avoid a stack overflow, big objects should be allocated to the heap (correct me if I am wrong). But, since the heap and the stack expand towards each other, wouldn't this cause heap overflow or alternatively limit the space for the stack and higher the chances of stack overflow?


title: The best approach to building a mobile service that's also available when the connection drops?

text: Hopefully this question will be a good suit for P.SE since it is a whiteboard- level 'how can this be done' conceptual question. I'm trying to build a product that needs to be available to someone on the move with a mobile device when their connection may be quite poor (due to travelling between cities where 3G coverage is stronger). For simplicity, let's say the application is an address book. The user must be able to add/remove/edit all contacts in the address regardless of connection state, then those changes iterated to a central server DB whenever the connection next becomes available (and any changes made on the server since the connection dropped also downloaded). I was originally building the application with PHP/Symfony working with static pages but this new 'mobile' requirement has made me re-think my front-end technology. I'm now looking at using EmberJS for my frontend (download all the necessary frontend templates with the initial request, then only update the dynamic parts seems like it would suit my application better than serving an entire static page (and resources) for every request). I've been implementing Ember-Data with the standard REST Adapter which is working great with my already-existent Symfony2 API, so I've greatly reduced the amount of data being sent/received and the responsive 'feel' of the app but still need to tackle my 'no-connection-available' scenario. Instinctively, I'm drawn to HTML5's LocalStorage functionality but can see synchronizing data between the localstorage and central DB server being a gigantic headache. Let's say I add "Bob Smith" to the address book from my mobile when the connection is up. The connection drops. I change the name to "Bob Jones" and then change the name to "Fred Smith" using a desktop with a stable connection. When the mobile re-connects, which update takes precedence? I saw this question regarding using multiple data adapters (REST and LocalStorage) with Ember and it looks like I'm in for a world of hurt. Should I just build a nice-responsive version of the app/service with Ember/REST Adapter, then roll native mobile apps for the on-the-move version? Will handling data persistence be easier to handle as a native app?


title: How to split up ASP MVC Project using Code-First Entity Framework

text: For an academic exercise, we have been tasked with creating a small website. We have already gathered the requirements and fleshed out the business domain to see the classes we are supposed to support. It is to be on Microsoft stack, so I decided to use _ASP MVC_ with _code first Entity Framework_. I am now looking for the best way to split up a 6 man team in order to best tackle the project. **TLDR:** What are some effective ways of splitting up an ASP MVC project so that multiple developers can work on it concurrently? I have researched where projects have been split across the tiers, i.e. _database, business, views_ , and such, but I don't exactly know how to instruct them to go about designing a view for which there is no controller. Is splitting it up between the different business models used a decent strategy? I have read that this has led to an application that didn't mesh well, due to the different aesthetics.


title: When is a number a magic number?

text: Over the last couple of months I have been diving into coding standard IfSQ. As a part of this IfSQ standard, a rule is to not use `Magic Numbers`. While I don't have a problem with building this rule into checks as FxCop or StyleCop, I am confused as to what actually IS a Magic Number. According to Wikipedia there are 3 explanations of magic numbers:   1. A constant numerical or text value used to identify a file format or protocol;   2. Distinctive unique values that are unlikely to be mistaken for other meanings (e.g., Globally Unique Identifiers);   3. **Unique values with unexplained meaning or multiple occurrences which could (preferably) be replaced with named constants.** I am focussing on the third meaning. But this is also where I am stuck. Seeing as I am trying to build this in a FxCop rule; the check has to be automated. But what am I supposed flag as magic number? The IfSQ standard explains the following as magic numbers: `Numeric literals (other than 0 or 1) have been embedded directly into the source code. For example "34" or "86400".` But this doesn't sound good to me at all. This would mean I'd have to flag every single occurence of a number other than 0 and 1. Numbers like 24 (hours), 60 (minutes) and 100 (percentage) are, in their correct context, no magic numbers; in my eyes that is. Because this is will be an automated check, looking from things in a contextual way isn't really possible. Based on this I have the following questions:   1. How should I define a magic number?   2. Is it possible to define magic numbers without context?   3. Should I skip certain statements when checking for magic numbers?


title: Why Java doesn't make use of encapsulation with some classes?

text: My question is related with `System.in` and `System.out` classes (there might be others like those in the Standard library). Why is that? Isn't that a bad practice in OOP? Shouldn't it be used like: `System.getIn()` and `System.getOut()`? I've always had this question and I hope I can find a good answer here.


title: Backlog item with preparation for future sprint Scrum

text: I'm currently at the beginning of a build. We are requiring a lot of back end functionality around Clients/Users/Groups/Roles. However, these aren't required for Sprint 1 which is acting as a MVP release. But I want to ensure we are preparing for this enhanced back-end in the future. This is easiest by defining an interface to the User Management system without actually building all of it yet. How would you organise this in a Scrum project environment? Obviously, in order to decide how the interface needs to look. We need to decide on it's functionality. But in doing so, we'll be getting very close to speccing the entire thing out. Which isn't required for several months! (This is a Team Foundation Scrum 3.0 workflow for those interested)


title: MVVM ViewModel and Commands

text: I need a bit of help to understand the relationship between a viewmodel and a command, and the responsibility of the viewmodel. I'll try to give an example (using Caliburn Micro). I have a viewmodel class, a command class and a view with a Save button.               public class EditViewModel : Screen     {         public bool CanSave         {             get { return IsDirty; }         }              public void Save()         {             var command = new SaveCommand(this); // command gets reference to VM             command.Execute();         }     }          public class SaveCommand     {         private readonly EditViewModel _viewModel;              public SaveCommand(EditViewModel viewModel)         {             _viewModel = viewModel;         }              public void Execute()         {            var work = _viewModel.Work;            ..            _viewModel.IsDirty = false;         }     }      When the user click Save. Save() method is called and spins up a command that saves the work. Now my question is, should the command have a reference to the viewmodel? No) The viewmodel will have to pass the work to the command, which will have to pass the save result back to the viewmodel, which will update itself. Yes) The command needs a reference to the viewmodel and properties needs to be public set-able. _No_ seems like the cleanest way, but also requires extra work, when the work or result aren't a simple bool or similar. I guess the root it all is. What is the relationship between a viewmodel and it's command and the responsibility of the viewmodel ? Is there a strong 1:1 "friend" relationship between the view-model and it's command, where code has just been moved to another class. So there is nothing wrong with the command having direct access to the viewmodel. Another understanding, the viewmodel is a very simple class, almost only with properties and contains little logic. So the logic should be in the command. Or the viewmodel is pretty smart and should contain application-logic. Commands are really only needed when there are either too many in one viewmodel or they are a bit complicated otherwise the command code can stay in the viewmodel. I'm just rambling I guess, please help me out to understand the viewmodel and what it's responsibility is?


title: bad practice to have actions in web api controllers

text: I was creating a new action for a `WebApi` controller and tried to create a url using the following:               @Url.RouteUrl("DefaultApi", new { httproute = "", controller = "ClientApi"})      and noticed that the default route did not have an action attribute, it looks like this:               config.Routes.MapHttpRoute(         name: "DefaultApi",         routeTemplate: "api/{controller}/{id}",         defaults: new { id = RouteParameter.Optional }     );      how come the default route doesn't have the action in the route configuration by default? is it bad practice to have it? that is to say is it bad practice to have so many actions in a web api controller that it requires to change the route.


title: I've unit tested my class, now how do I get started with an integration test?

text: I've written a class that manages recipients on a MailChimp list, called MailChimpRecipient. It uses the MCAPI class, which is an third-party API wrapper. http://apidocs.mailchimp.com/api/1.3/ http://apidocs.mailchimp.com/api/downloads/ I pass the MCAPI object into the constructor of the MailChimpRecipient object, so I have written unit tests using PHPUnit that test all of the logic in my own class (I am not testing the MCAPI class). I have 100% code coverage and all tests pass. This is done by mocking and stubbing the MCAPI object. My next step was to write an integration test, also using PHPUnit, where I would construct the MailChimpRecipient fixture using a real MCAPI object, set up to use a real MailChimp list. I have written what I think is an intergration test, which basically runs tests agains the public interface of the object, like:               public function testAddedRecipientCanBeFound()     {         $emailAddress = 'fred@fredsdomain.com';         $forename = 'Fred';         $surname = 'Smith';              // First, delete the email address if it is already on the list         $oldRecipient = $this->createRecipient();         if($oldRecipient->find($emailAddress))         {             $oldRecipient->delete();         }         unset($oldRecipient);              // Add the recipient using the test data         $newRecipient = $this->createRecipient();         $newRecipient->setForename($forename);         $newRecipient->setSurname($surname);         $newRecipient->setEmailAddress($emailAddress);         $newRecipient->add();         unset($newRecipient);              // Assert that the recipient can be found using the same email address         $this->assertTrue($this->_recipient->find($emailAddress));     }      The "integration" test doesn't test any of the internals of the class - it just makes sure that given a real MCAPI object, it behaves as advertised. Is this correct? Is this the best way to run an intergation test? After all, the internals have been tested with a unit test. Am I right in thinking that the integration test is there to test that it really works, according the way its behaviour is advertised? To take it a step further, the MailChimpRecipient class implements an interface, which will also be implemented by other classes. The idea is to use a factory to pass different types of mailing list recipient objects to my code, which all do the same thing, albeit using different mailing list providers. Since my integration tests test the that interface, how about using it for all of the classes that implement the interface? Then, in the future, if I design a new class to be used interchangably, I can run the same integration test before inserting it into a project. Does this sound reasonable? The unit tests test the internals of an object, intergration tests make sure that it behaves as advertised?


title: Using the STL to solve interview questions?

text: If I'm undergoing a technical interview that's based on my C++ skills, would most companies allow or expect me to use STL containers to solve problems? I think it's clear that if a question is pertaining specifically to a linked- list and my knowledge of linked-lists that I probably won't be able to or shouldn't use the STL list containers. On the other hand, I could get a question where using std::vector might be really useful and the question itself doesn't concern std::vector directly. In this latter case I would think using the vector STL container would be acceptable. Of course, the answer to this question is at least somewhat company dependent. I'm curious as to how bigger tech companies approach this situation.


title: thick client migration to web based application

text: This query is related to application design the technology that I should consider during migration. The Scenario: I have a C#.net Winform application which communicates with a device. One of the main feature of this application is monitoring cyclic data(rate 200ms) sent from the device to the application. The request to start the cyclic data is sent only once in the beginning and then the application starts receiving data from the device until it sends a stop request. Now this same application needs to be deployed over the web in a intranet. The application is composed of a business logic layer and a communication layer which communicates with the device through UDP ports. I am trying to look at a solution which will allow me to have a single instance of the application on the server so that the device thinks that it is connected as usual and then from the business logic layer I can manage the clients. I want to reuse the code of the business layer and the communication layer as much as possible. Please let me know if webserives/WCF/ etc what i should consider to design the migration. Thanks in advance.


title: How do I / what is the best way to interact with a desktop application from a browser web application?

text: Situation: We have a desktop application. We also have a web application. We need the two to interact with each other. So when a button is pushed in the web application, the desktop application needs to start running a process (pulling data from the cloud using an API we've created). With two local applications, this can be done with ports/listening, editing a flag somewhere locally, and the other application reading this flag, etc. Can this be done from web -> desktop? Ideally the web application would have direct communication with the desktop application and notify it to begin pulling data down from the cloud using our API. But if this is not possible, having the desktop app run a process that loops and checks for a flag in a file or something would be a good start. After minimal research, I've found some stuff like HTML5 File Api which interacts with "Sandbox" directory on the local machine. I've also read that it is impossible to access any thing on the local machine for security reasons. Also, I dont want the user to be prompted to request a download file everytime, we need things to happen behind the scenes. (Even if the user has to initally set up some lower security / permissions just for this situation) Any input is appreciated!


> **Possible Duplicate:**   >  Career Prospects: Women at Management positions in Software Why are there so few female programmers? My wife asked me and I didn't know.


title: I know what I want to do, but I have a hard time coding it?

text: After doing some interviews, I've realized that I usually know what I want to do to solve a problem, but I often get my logic complicated (and introduce a lot of bugs) when I'm actually coding. For example, when I tried to code up insertion into a sorted singly linked list, this is what I knew I had to do:   1. I had to check for the case where the list is currently null   2. I had to check if the element I want to insert is less than the current head   3. To insert between nodes, we had to link one node to the new node, and the new node's next to the one that is supposed to be after. I had trouble inserting between nodes because I was actually supposed to check the NEXT node's data and not the node which I had my pointer pointing to (so I could set current's next to the new node). I also struggled on this problem (note that this was coded on white board) because I was pressured under time and I think I made it more complicated in my mind that I should have. When I went back to this problem after the interview, it turns out the solution isn't complicated at all (as it shouldn't be). However, I just tend to complicate things and confuse myself. Would anyone have any suggestions on how I could improve this vulnerability of mine?


title: Building a database class in PHP

text: I wonder if I should write a database class for my application, and if so, how to accomplish it? Over there on SO, a guy mentioned it should be written as an abstract class. However, I can't understand why this would be a benefit. Do I understand correctly, that if I would write an abstract class, every other class that methods will need a database connection, could simply extend this abstract class and have its own database object? If so, how is this different from a "normal" class where I could instantiate an database object? Another method would be to completely forget about my own class and to instantiate a mysqli object on demand. What do you recommend?


title: Emulation of MMU accessing the contents of the registers

text: I'm having a play around with emulating a simple old CPU. I've set the structure up, so far anyway, as follows: The device is the main and creates an instance of the CPU. The CPU then creates instances of the registers, clocks and MMU. I'm in the position where the MMU needs to access the contents of the registers, how to do this? I figure I could probably bodge something together by passing the entire register object to the MMU when it's called but that seems unwieldy. The other thing I thought to do would be to initialise the MMU with the register object in the constructor. If I'm not mistaken that will still reference the same object? Meaning any changes I do to the registers in the MMU will affect the whole system?


title: Why is iOS "jailbreaking" CPU specific?

text: Recently, iOS 6 was "jailbroken" but only on the Apple A4 CPU. Why is the "jailbreaking" process specific to a CPU? From Wikipedia: > ... "iOS jailbreaking is the process of removing the limitations imposed by > Apple on devices running the iOS operating system through the use of > hardware/software exploits – such devices include the iPhone, iPod touch, > iPad, and second generation Apple TV. Jailbreaking allows iOS users to gain > root access to the operating system""" ...


title: Making Code Changes While PHP Script Is Running

text: I have a PHP program running right now that is processing database rows of over 6 million. Considering the speed at which number of records have been processed so far, it looks like the whole process might take few days to complete (due to hardware limitations). I was thinking if I could make changes in the program to remove unnecessary logging and other things that may be consuming time. Can I do this with the current program still running so that further processing would speed up, or will this cause the PHP script to break ?


title: Linking application build number to svn revision

text: I am looking for a strategy to version an application with the following requirements. My requirements are given an exe with version number (major.minor.build- number) 1) I want to map the version to a svn source revision that made the exe 2) With the source and exe I should be able to attach and debug in vs2010 with no issue. 3) Once I check-out the source code for the exe I should be able to build the exe again with the version number without having to make any changes to a file.


title: Company wants thoughts about their site during interview

text: I have an initial phone interview coming up with a company for a Senior Web Developer position and in the email they asked to prepare by signing up on their site because they'd like to hear my thoughts about it and suggestions for improvement. I've heard stories before of companies that do this. They interview 10 people and then if everyone gives advice, then they've got a lot of free consultation. I believe this is the first time I've ever been asked to do something like this so I wanted to hear other people's thoughts of whether it is free consulting or if I'm just being paranoid.


title: How should I get my code ready for OpenSourcing it and putting it on GitHub?

text: In a few weeks, my project is going to be finished and I want to start getting my code ready for other people to use it. I am going to be posting everything to GitHub so people can tweak it and hopefully make it better. I guess what I'm asking is, what would be the best way to make sure my code is sufficiently documented and worded right for other people to use? I know you should always comment everything and I'm going to be putting in the @params feature for every method, but are there any other tips in general?


title: What are the most important concepts to understand for "fluency in developer English"?

text: In April, I'm going to be giving a talk called **English 2.0 - Understanding the Language of Developers" to a group of English teachers. The purpose is in two hours to give them a quick background in key concepts so that they can better understand developer blogs and podcasts and are able to ask better questions when talking to developers. What do you think are the most important concepts to understand, concepts that developers take for granted but the general public is not familiar with? Here are a few ideas:   * version control   * abstractions   * pub/sub   * push vs. pull   * debugging   * modularity   * three-tier architecture   * class/object   * "spaghetti code" vs. OOP   * exception throwing   * crowd sourcing   * refactoring   * the cloud   * DRY - don't repeat yourself   * client/server   * unit testing   * designer/developer


title: From non programmer to "professional" freelance programmer

text: I am 15 year old student looking to buy his first car and thought I could earn some extra money by learning to program since I like messing around with the computer all the time. I have been reading a lot of the posts here and have come up with a list of books I think would be beneficial to me, however, I do not know which information is most important to know first or if I have everything I will need. Here is what I was thinking: 1: Learn a programming language in depth. I am about 1/2 way done with the Step-by-Step book 2\. Learn about object oriented design and design patterns 3\. Learn about software testing 4\. Go practice these skills on websites like projecteuler, topcoder, and try and do simple projects on freelance websites like rent-a-coder. Is there anything else you think I may need or should look into? Thank you. Microsoft Visual C# 2010 Step by Step Professional C# 4.0 and .NET 4 (Wrox Programmer to Programmer) C# in Depth CLR via C# Applying UML AND Patterns Head First Object-Oriented Analysis and Design Design Patterns: Elements of Reusable Object-Oriented Software Test Driven Development: By Example Growing Object-Oriented Software, Guided by Tests


title: Participating in Webinars and Seminars about Developing and Programming

text: Does participating in Webinars and Seminars about software development and programming improve a developer's programming level? Please note that I'm asking this question about developers, not managers. Because in many webinars and seminars, there are highly general views about future technologies which can be useful for manager to decide ahead about future tools their team should use.


title: Avoid losing time making budget

text: I often receive some potential client who wants me to make his web site. Some of them end up as real clients and give the project. Some others (the most) have no idea about prices and times. For those, if they are close to me, I can hear what they want, tell them it is going to be about X money and Y time and it can go higher or lower. If they had that idea in mind then I use the time I need to make the right budget. Now, for the cases that they are not so close to me, I have to lose the time to make the right budget from the beginning. If the budget is accepted I would get paid for that time because I included it, but if it is not accepted, I'd have lost lot of time without being paid. How can I avoid losing that time?


title: What kind of algorithm could be used to produce an ordering which maximizes # of satisfied 'less than' constraints?

text: Let's say I have a set of items {e1, e2, ..., en}, and I also have a set of constraints {c1, c2, ..., cm}, with ci := ej appears before ek, for some j and k. I want to produce an ordering of my items which maximizes the number of satisfied constraints, with the possibility that some of the constraints are contradictory. I'm not sure how to search for this, but I hope there is some known efficient algorithm for this. It might also be helpful if, given weights for the constraints, I could instead maximize the total weight of the satisfied constraints, rather than just the number.


title: Why And is needed when there is AndAlso

text: I have referred What is the difference between And and AndAlso in VB.net? to understand the difference between `And` and `AndAlso`. I am from C# background - and C# has `AndAlso` only - no `And`.. And I don't see any practical use/advnatage of `And`. Is there any practical use of `And` in VB.Net? **Reference**   1. Or versus OrElse   2. What is the difference between And and AndAlso in VB.net?


title: Unable to convince on data hiding

text: I am working on a Selenium + java project where all Web Element in a class are declared as -               public class CheckoutPaymentConfirmpage extends WebPage{          public final Button btnPrintorder = new Button("//input[@id='but_Print']");     public final TextField txtpassword = new TextField("password", "//input[@id='pass']");              // Some more elements here         // Some page object methods here     }      Now when ever test need to access these elements they are directly invoked over the object of `CheckoutPaymentConfirmpage` class What ever little java (or OOPS) I know, has taught me that members should be as hidden as possible. Hence I would have had `btnPrintorder` and `txtpassword` declared private and would access them using getters or would have created methods in page object class to be used by tests. But when I convey this to others they don't see much value in it as state of instance variable (i.e. `btnPrintorder` etc) would not be changed from one object to another for page object class (i.e. `CheckoutPaymentConfirmpage` etc) Hence in this situation, is it ok to leave instance variable as public?


We have developed one product for payroll processing. We have 10+ customers who are using this software product. Our existing and new customers are giving us customization changes w.r.t. their needs, and now we are facing the problem of product management. Please give some guidelines to us. How to manage single software product to multiple customers? Software developement details :   Front End Tools : Visual Studio 2008 (ASP.net web application)   Source Code Mangement : Visual Source Safe (VSS)   Back End : Sql Server 2005   Team Size: 12


title: Are asp.net web parts good enough for exclusive development?

text: I have had the question posed at my work that, since we are planning to eventually move to Sharepoint 2010 for most of our Development, and since Sharepoint 2010 supports asp.net web parts, should we start moving all of our new development to be exclusively asp.net web parts? It was also asked how prism factors into all of this. (not sure what that is) We are now a mostly client/server based location but are moving to an SOA framework (slowly though). Is this a good idea? Is it better to have some apps in WPF and Winforms hitting the services or should we just go to web parts solely? What are we going to miss out on if we make this move?


title: How to organize integration tests and test data for different environments when using Maven Failsafe

text: I have started to separate my unit tests from my integration tests by using Maven Surefire and Failsafe. Now I'm wondering what good ways there are to deal with separate environments. Take for example these two integration tests scenarios:   * Given a customer id, can I get a list of orders belonging to that customer.   * Given a customer id and a product id, can I create an order for that customer. I want to be able to run these tests against both TEST and PRODUCTION environments, but they will need different data and in some cases slightly different code as well. In some cases there are also tests I might not want to run in PRODUCTION, but only in TEST. For example my test customer won't have the same id in both TEST and PRODUCTION. And when I need to create the product for the order I might need to instantiate a different product (with different properties, etc). What are some good ways of tackling this without too much of a mess or duplicated code?


title: Strategy for maintaining assembly references in TFS

text: I have a 3 branch setup: Dev, QA, Prod. There is a references folder where we store common 3rd party and internal assemblies. Change mgmnt has been challenging. Sometimes Devs forget to go into the References folder and check in the new version. We tried referencing Projects, which results in a reference to the bin folder. This works out fine as long as you keep the build order correct and always contain all the projects in the same solution file. This isn't always a good idea or feasible, so we went to a references folder. Continuous Integration may help alleviate some of these issues, but we don't have a CI server yet. Is there a good process for for managing the References folder that doesn't require so much manuel dev intervention? I thought about copying the files out on post-build. That doesn't solve the issue of checking the new version in so other devs can access it. We have TFS. This is for internal corporate development. Anything that requires open-source of our product is not possible. **UPDATE**   I own FinalBuilder. I am new to using it and do not know if it can benefit this process.