Encapsulating a class within another class to hide its exposed properties and details

I have essentially a data model class that represents an XML data structure that we use to model our system. The model class is in a shared project that is used by a number of different solutions in order to generate a common XML data structure for usage by any number of applications. In one application I am involved in we have provided a wrapper class for one of these XML model classes as we wish to perform a number of operations on the model data. However other parts of my program also needs to access this data for calculations they need to do. At the moment I have this setup (note this is an example only but represents my code structure) 1)               public class ModelWrapper     {         private readonly ModelClass _model;              public int PropertyX          {            get            {               return _model.PropertyX;           }         }              public ModelWrapper(ModelClass model)         {            _model = model;           }              // and other methods we need that uses the properties we have exposed e.g         public void PerformOperation()         {             if(this.PropertyX > 10)                // do something             else                // do something else         }     }      This appears ok, but I've run into the problem where I or another programmer has un-intentially used the private _model variable. It seems to me that we could end up with hidden issues in this method in the fact that there are two ways to get to the same data and if we put some logic in the public exposed get property then we could miss that if we directly reference the private variable. The other alternative I thought of was 2)               public class ModelWrapper     {         public readonly int PropertyX;              public ModelWrapper(ModelClass model)         {            PropertyX = model.PropertyX;              // set other properties here we wish to expose on the ModelClass ...         }              // and other methods we need that uses the properties we have exposed e.g         public void PerformOperation()         {             if(this.PropertyX > 10)                // do something             else                // do something else         }     }      Or another option after reading some posts about this is: 3)               public class ModelWrapper     {         private readonly int _propertyX;         public int PropertyX          {            get { return _propertyX; }         }              public ModelWrapper(ModelClass model)         {            _propertyX = model.PropertyX;           }              // and other methods we need that uses the properties we have exposed e.g         public void PerformOperation()         {             if(this.PropertyX > 10)                // do something             else                // do something else         }     }      Why do this? I thought it would be a good idea to hide the model from the our code as we wanted a wrapper class anyway to do the methods so why then expose the model as well? I thought it might be overkill but it does save in other parts of the code going something like **ModelWrapper.Model.PropertyX** etc So to the question. Which method if any would be a better solution. Is it overkill or are there better practices out there for this? EDIT: I added another option (3) as it there is no need to set the properties I am exposing so I didn't necessarily want to have a private set as it's only being set in the constructor. Hence the readonly private variable that is used in the get part of the exposed property? I've also found a stack overflow question about this at http://stackoverflow.com/questions/2249980/c-immutability-and-public-readonly- fields but it doesn't necessarilly say which was better/preferred solution with the current c# limitations. Any ideas on the 3 implementations as to the best practice?


Rails solution for mobile-specific content filter?

To note, I'm not interested in simply 'hiding' content for mobile devices, I want to filter out that content completely. I'm also not trying to address the issue by building a mobile specific interface (mob.example.com). There was another question regarding something similar: How do I prevent useless content load on the page in responsive design? The solution, in that post, was to set a session during the initial request, and then use the session to filter content on subsequent requests. I primarily develop in Rails, and I'm wondering if there are any gems or ruby- specific solutions to this problem?


Business Objects within a Data Access Layer

So I've been creating a data access layer via TDD and have approached somewhat of a concern. I'd rather not start down the wrong path, so I figured I'd ask you guys to see if my thoughts were in line with a clean architecture. The methods within my Data Access Layer (DAL for short), are pretty simple. They are in line with the stored procedures in the database (no other way to call into it to keep things clean), and they contain those same parameters that the procedures do. They then just connect to the database, and return the query result. Here's one example:               public int DeleteRecord(int recordId)     {         recordId.RequireThat("recordId").NotZeroOrLess();              List<SqlParameter> parameters = new List<SqlParameter>();         parameters.Add(new SqlParameter { ParameterName = "@RecordId", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Input, Value = recordId});              return this.ExecuteNonQuery("DeleteRecord", parameters.ToArray());     }      This works perfectly for this type of method because I am not doing anything meaningful with the result set. I just want to make sure the command worked, so I will return the result of the non-query, which is just the rows affected, and I can verify the logic using that number. However, say in another DAL method, I want to load a record. My load procedure is going to be executing `selects` against a bunch of tables and returning a `DataSet`, but I am battling with whether my DAL should create the Business Objects within the method using the `DataSet`, _or_ if my Business Objects themselves should just have a `Load()` method that gets the `DataSet` from the DAL, and then basically fills itself in. Doing it through the DAL would result in less logic in the Business Objects (even though this is just select logic, it's still logic), but would crowd the DAL a little bit and make it feel like it really is doing something that it shouldn't be doing. What do you guys think?


Difference between Controller and Dispatcher in MVC for web frameworks?

In MVC applied to WSGI or Java EE, is the Servlet a controller, dispatcher, or both? I think I've seen system diagrams where the controller and the dispatcher are different. Could the controller control SQL statements which should not be in the dispatcher? Thank you


Advice on whether to use scripting, run time compile or something else

I work in the prodution area at my works and I design and create the software to run our automated test equipment for testing our products. Everytime I get involved with a new machine I end up with a different and (hopefully) better design. Anyway I have come to the point where I feel I need to start standardizing all the machines with the same program. I see a problem when it comes to applying updates as at the moment the test procedures are hard coded into the program at each station. I neeed to be able to update the core program without affecting the testing section. The way I see it is that this will mean splitting the program into 2 sections.   1. Main UI - This is the core that talks to everything on the machine such as cameras, sensors, printer etc and is a standalone application.   2. Test Procedure - This is the steps that is executeted everytime the machine runs through a test. The main UI will load the test procedure and execute when ever a test is required. My question is what is the best approach to this in terms of having an application load a file and execute the code with in? Take into account that the code in the test procedure will need access to public methods on the UI/core system to communicate to sensors etc. I have heard about MS Roslyn and had a quick look, would this solve my issue?


How can I document someone else's past work?

We're in a bad situation of having very little documentation on customization our past workers made to a business critical system. Lots of changes were done to Crystal Reports, database entities, and proprietary configuration/programming files for our ERP software. The current documentation generally reads something like this: > This program is run before invoicing. Known bugs: none. > > Run this program after installing software X. > > Changed the following fields in this report: (with no explanation of how or > why) Our IT shop is small, and in the case of the ERP software, most work was lumped on one person (that's me now) so no one else here knows what all we did. The IT and accounting department know bits and pieces (occasionally quite helpful ones) but it's not enough. Another problem is our Accounting department seems to _think_ we're well documented. It's true that we kept lots of records of what went _wrong_ , but very little explains what (if anything) was done to fix these problems. We have hundreds of papers explaining bugs, but the documents explaining changes (as shown above) are almost useless. **How can I go about documenting past changes when I don't know what all was done?** I can start with documenting _what_ we've changed: Files, database tables ect which we need to have for the system to work. I can also document what we _do_ ; when reports are run, why people were told to use X report/program. But when one of these customized things has a problem, I'm always back to square one. How can I proactively document this stuff for myself and others?


DAO/Webservice Consumption in Web Application

I am currently working on converting a "legacy" web-based (Coldfusion) application from single data source (MSSQL database) to multi-tier OOP. In my current system there is a read/write database with all the usual stuff and additional "read-only" databases that are exported daily/hourly from an Enterprise Resource Planning (ERP) system by SSIS jobs with business product/item and manufacturing/SCM planning data. The reason I have the opportunity and need to convert to multi-tier OOP is a newer more modern ERP system is being implemented business wide that will be a complete replacement. This newer ERP system offers several interfaces for third party applications like mine, from direct SQL access to either a dotNet web-service or a SOAP- like web-service. I have found several suitable frameworks I would be happy to use (Coldspring, FW/1) but I am not sure what design patterns apply to my data access object/component and how to manage the connection/session tokens, with this background, my question has the following three parts:   1. Firstly I have concerns with moving from the relative safety of a SSIS job that protects me from downtime and speed of the ERP system to directly connecting with one of the web services which I note seem significantly slower than I expected (simple/small requests often take up to a whole second). Are there any design patterns I can investigate/use to cache/protect my data tier?   2. It is my understanding data access objects (the component that connects directly with the web services and convert them into the data types I can then work with in my Domain Objects) should be singletons (and will act as an Adapter/Facade), am I correct?   3. As part of the data access object I have to setup a connection by username/password (I could set up multiple users and/or connect multiple times with this) which responds with a session token that needs to be provided on every subsequent request. Do I do this once and share it across the whole application, do I setup a new "connection" for every user of my application and keep the token in their session scope (might quickly hit licensing limits), do I set the "connection" up per page request, or is there a design pattern I am missing that can manage multiple "connections" where a requests/access uses the first free "connection"? It is worth noting if the ERP system dies I will need to reset/invalidate all the connections and start from scratch, and depending on which web-service I use might need manually close the "connection/session"


Should I include multiply license header notice in dual license software?

Is it necessarily if a software released under both of LGPL3 && GPL3 terms have to include both license header notice top of each file? Or just put GPL header notice? or simply put LGPL3 license text in some file like COPYING.LESSER ? EDITED: I am the copyright holder of the project!


Why isn't exponentiation hardware-implemented?

Why is there no exponentiation operation in hardware, even though many languages have builtin operators for it? Is it because even hardware implementations would need to use the same algorithm as software (i.e. no hardware implementation could be significantly more efficient), or because it is rarely used, or another reason?


Lists & Collections in MVVM - which approach to take?

I'm currently working on a Silverlight app using Caliburn.Micro. At present, we have Views (eg: `PeopleView`) and View Models (eg: `PeopleViewModel`) that equate to 'pages' of the application. `PeopleView` might contain a `ListBox` ("`People`") which is bound to an `ObservableCollection` of `Person` objects, and has an `ItemTemplate` assigned to denote how each `Person` object should be displayed. However, one of my colleagues has begun to implement a list in another way, where each `Person` is a View Model (ie: `PersonViewModel`) and has an associated `PersonView` to determine how that `PersonViewModel` should be displayed in the `ListBox`. The latter seems more MVVM (or at least has more mention of V and VM!) but I'm not sure whether there's a particularly large advantage to doing one over the other. Are both of these ways valid? Is either better than the other?


What issues carry the highest risk in a software project?

Clearly, software projects are different from other industries in terms of many things like for instance, quality assurance, project progress measurement, and many other things. Unique characteristics of software projects also makes the risk management process unique. Lots of issues in a project might lead it to unacceptable delay or failure to deliver business value. They might even make a complete disaster in the project. What are the deadliest risk factors in a software project? How to analyze, prevent and handle them? Particularly, I'm interested in the issues that you can detect from the beginning and you should keep an eye on (for example, you might be told about a third-party API that the current application uses and lacks documentation). Please share your experiences if they are relevant.


Use of malloc in C

Is it necessary to call free function every time we use malloc in C. I am asking this because I have seen many times that it is not called . Thank you


Is it better to have constructors with or without parameters?

Is it better to have constructors with or without parameters and why?               public NewClass( String a,  String b, int c) throws IOException     {         //something     }      _OR_               public NewClass()      {         //something     }


Testing a codebase with sequential cohesion

I've this really simple program written in C with ncurses that's basically a front-end to sqlite3. I would like to implement TDD to continue the development and have found a nice C unit framework for this. However I'm totally stuck on how to implement it. Take this case for example: A user types a letter 'l' that is captured by ncurses getch(), and then an sqlite3 query is run that for every row calls a callback function. This callback function prints stuff to the screen via ncurses. So the obvious way to fully test this is to simulate a keyboard and a terminal and make sure that the output is the expected. However this sounds too complicated. I was thinking about adding an abstraction layer between the database and the UI so that the callback function will populate a list of entries and that list will later be printed. In that case I would be able to check if that list contains the expected values. However, why would I struggle with a data structure and lists in my program when sqlite3 already does this? For example, if the user wants to see the list sorted in some other way, it would be expensive to throw away the list and repopulate it. I would need to sort the list, but why should I implement sorting when sqlite3 already has that? Using my orginal design I could just do an other query sorted differently. Previously I've only done TDD with command line applications, and there it's really easy to just compare the output with what I'm expected. An other way would be to add CLI interface to the program and wrap a test program around the CLI to test everything. (The way git.git does with it's test-framework). So the question is, how to add testing to a tightly integrated database/UI.


WCF Data Services (OData) Vs ASP.NET Web API? Hypermedia?

I'm desiging a distributed application that will consist of REST services and a variety of clients (Silverlight, iOS, Windows Phone 7, etc). I was ready to decide that I would implement my REST services using WCF Data Services (OData) but now the the MVC 4 Web API has made me question that decision. What I liked about OData was the URI querying and hypermedia capabilities you get for free. What I disliked was the verbosity of the OData payload; lots of unnecessary characters coming over the wire. What I like about the Web API is that the payloads are much more concise and it has the URI querying capability of OData, however it seems to be lacking hypermedia (out of the box, at least). My boss is also pushing for the Web API because "the powers that be at Microsoft are backing it and OData hasn't been getting traction." So I have two questions: 1) Can anyone comment on the backing/traction of the Web API and OData? 2) Is the Web API expected to natively support hypermedia by release time or are there any off-the-shelf implementations or examples I should look into? Thanks!


Scheduling Algorithm for Scheduling Life

I am trying to write some code to schedule a set of real life tasks that are input by the user. These tasks are stored in an sqlite database. And at the moment, the only parameters I am taking into consideration are the, `The project to which a task belongs to --> p`   `The name of the task itself --> t`   `And the due date for this task --> d` The `project` and `due date` parameters are optional. But assuming that the user will always input at least the `task name` and `due date` for every task.. I was wondering if it is possible to schedule the set of tasks using a scheduler like the `Completely Fair Scheduler (CFS)` for example!. I realize that the CFS was written for scheduling tasks with much finer granularity(nanoseconds) than the set of tasks being proposed for this purpose... But I realized that it might be possible and maybe more efficient if I can modify it to work with tasks that are on the same time scale as our perception of time. A typical entry in the database would be in the format (p, t, d). 'p' is optional. Here are a few examples.. `(_, 'Call home', 29/2/2012)`   `(Work, 'Meet boss', 14/3/2012)`   `(Work, 'Ask for raise', 18/3/2012)`   `(_, 'Book tickets', 10/3/2012)`   `(Work, 'Quit', 14/4/2012)`   `(Personal, 'Get botox injections', 10/3/2012)`   `(Personal, 'Get breast implants', 10/10/2012)`   `(_, 'Dad bday', 7/10/2012)` Here is a situation to consider. I would like to wake up in the morning. Run this "yet to be coded" algorithm on the set of tasks.. like the ones given above.. and I would like to receive a schedule for the rest of day, that maximizes throughput. At a later stage, I would like to pass arguments to this algorithms that would allow me to control the scheduler to return a set of tasks depending on my current situation. Like if I am at work, I want to be able to pass arguments to the algorithm, to ask it to only return tasks that can be completed at work.. I hope I am able to convey the gist of it. I understand that the `due date` alone is not sufficient to schedule tasks using the CFS for example.. but if there are other parameters that I should consider, please do let me know. And any suggestions for the kind of scheduling algorithm to employ would be helpful. Thanks.


Is creating a separate pool for each individual png image in the same class appropriate?

I'm still possibly a little green about object-pooling, and I want to make sure something like this is a sound design pattern before really embarking upon it. Take the following code (which uses the Starling framework in ActionScript 3):               [Embed(source = "/../assets/images/game/misc/red_door.png")]     private const RED_DOOR:Class;          private const RED_DOOR_TEXTURE:Texture = Texture.fromBitmap(new RED_DOOR());          private const m_vRedDoorPool:Vector.<Image> = new Vector.<Image>(50, true);     .     .     .     public function produceRedDoor():Image     {         // get a Red Door image     }          public function retireRedDoor(pImage:Image):void     {         // retire a Red Door Image     }      Except that there are four colors: red, green, blue, and yellow. So now we have a separate pool for each color, a separate produce function for each color, and a separate retire function for each color. Additionally there are several items in the game that follow this 4-color pattern, so for each of them, we have four pools, four produce functions, and four retire functions. There are more colors involved in the images themselves than just their predominant one, so trying to throw all the doors, for instance, in a single pool, and then changing their color properties around isn't going to work. Also the nonexistence of the static keyword is due to its slowness in AS3. Is this the right way to do things? * * * **EDIT:** One individual piece of the puzzle is whether I should be trying to throw all of these pools into the same class, with brand new functions and everything for each and every pool. That is somewhat related to another question I asked recently. Even though the accepted answer of that question didn't necessarily address this particular scenario, getting more classes, variables, abstractions, etc. is going to create more overhead, and when you're trying to do something like object pooling, I'm not sure whether neatening up the class design like that is going to introduce "too much" overhead. This is only one individual part of what I'm asking though, as the question is ultimately much more general.


Advice on designing a robust program to handle a large library of meta-information & programs

So this might be overly vague, but here it is anyway I'm not really looking for a specific answer, but rather general design principles or direction towards resources that deal with problems like this. It's one of my first large-scale applications, and I would like to do it right. **Brief Explanation** My basic problem is that I have to write an application that handles a large library of meta-data, can easily modify the meta-data on-the-fly, is robust with respect to crashing, and is very efficient. (Sorta like the design parameters of iTunes, although sometimes iTunes performs more poorly than I would like). If you don't want to read the details, you can skip the rest **Long Explanation** Specifically I am writing a program that creates a library of image files and meta-data about these files. There is a list of tags that may or may not apply to each image. The program needs to be able to add new images, new tags, assign tags to images, and detect duplicate images, all while operating. The program contains an image Viewer which has tagging operations. The idea is that if a given image A is viewed while the library has tags T1, T2, and T3, then that image will have boolean flags for each of those tags (depending on whether the user tagged that image while it was open in the Viewer). However, prior to being viewed in the Viewer, image A would have no value for tags T1, T2, and T3. Instead it would have a "dirty" flag indicating that it is unknown whether or not A has these tags or not. The program can introduce new tags at any time (which would automatically set all images to "dirty" with respect to this new tag) This program must be fast. It must be easily able to pull up a list of images with or without a certain tag as well as images which are "dirty" with respect to a tag. It has to be crash-safe, in that if it suddenly crashes, all of the tagging information done in that session is not lost (though perhaps it's okay to loose some of it) Finally, it has to work with a lot of images (>10,000) I am a fairly experienced programmer, but I have never tried to write a program with such demanding needs and I have never worked with databases. With respect to the meta-data storage, there seem to be a few design choices: **Choice 1** : Invidual meta-data vs centralized meta-data **Individual Meta-Data** : have a separate meta-data file for each image. This way, as soon as you change the meta-data for an image, it can be written to the hard disk, without having to rewrite the information for all of the other images. **Centralized Meta-Data** : Have a single file to hold the meta-data for every file. This would probably require meta-data writes in intervals as opposed to after every change. The benefit here is that you could keep a centralized list of all images with a given tag, ect, making the task of pulling up all images with a given tag very efficient


Offshoring a Software Project -- Conflict Resolution

I had been tasked with managing a project which was outsourced to some Ukrainian developers. The company hired them through Elance at a **fixed price**. At that point my boss left me _alone_ to handle them and get the work done. I created a detailed specification of the complete thing that needed to be done. The project involved dealing with such things as XMPP, RabbitMQ, and Database. In my first meeting with them (always IM) I explained **thoroughly** what they needed to do. They seemed to understand it -- and they were very confident that it would be done easily. So far so good. But after one week, when we met again, they were full of misunderstandings about what needed to be done. When I asked one of the developers if he knew XMPP, he said he was working with it for the first time. At our first meeting I'd very specifically mentioned the complexity of the project and the technologies involved. Plus, I had repeatedly asked them to write a functional specification of exactly HOW they would do it. But they said NO, and insisted that they would rather write the code. I said OK. The project completed after 3 weeks and they delivered what was needed. At that point I started to review the code. It was okay for the most part, but there ware some important problems:   * they hard-coded some of the things that needed to be separated out into a config file   * there were multiple config files that I needed to be consolidated in one   * they wrote absolutely NO documentation   * some other minor changes I asked them to make these changes (except documentation) -- And, we had an argument. They said, since the price was fixed, I was being unfair in asking them to make any changes once they completed the working code. That they had worked for unreasonable amount of time on the project and now it was completely wrong to ask for anything. Finally now they have made the changes, and the project is over. But it leaves some questions in my mind...   * They did what was needed but I needed it **properly done** , and hence the changes. was I really unfair?   * Why did I agree on letting them code without having a functional specification?   * Why did I not make sure that they understood everything the first time? Does anyone find themself in the same position? Do you think there is a better way to manage outsourced projects? _**\-- UPDATE --_** Thanks for all the opinions -- after reflecting upon entire experience, I can conclude...   * Although I wasn't vague in the specifications from my side, I certainly didn't make them _ironclad_ as suggested. So the take away is: always be as much specific as possible -- read your specs from their perspective too and see if you missed something. Repeat it at least three times.   * Just specifying what the code should do it not enough. You must specify what the code is supposed to look like. What the directory structure will be; even the file names if possible. This will save you from lot of annoyance later. Strictly specify the coding guidelines, variable naming conventions, internal documentation format, etc. See to it that they abide by those guidelines, and if not, scream.   * Demand a functional specification from their side -- insist that it be written before any code. This will get a lot of confusions and misunderstandings out of the way.   * Review the code as it is being developed so that you identify the anomalies earlier and get them corrected. Talk to them at least once every other day.   * Lastly, try to make a good rapport with them. Make them feel that you appreciate their work. Don't push them exaggeratedly to fit your guidelines -- instead request them to do so and tell them that it would make maintaining the code so much easier for you once they complete the project.


Long lines of text in source code

> **Possible Duplicate:**   >  Is the 80 character limit still relevant in times of widescreen monitors? I used to set a vertical line set at 80 characters in my text editor and then I added carriage returns if the lines got too long. I later increased the value to 135 characters. I started using word wrap and not giving myself a limit but tried to keep lines short if I could because it took a lot of time shortening my lines. People at work use word wrap and don't give themselves a limit.. is this the correct way? What are you meant to do ? Many thanks.


System analysis at the begining of the project

When I want to develop a new application, first I'm going to design a UML and specify project details and definition. But when I start development process, I determine that I should change some parts of my idea in order to become more popular software or easier logical steps for my users or simpler process or anything else. Then, I change my code, redesign some parts of my UML and start/continue development process one time again and sure that this time I have a perfect project definition and UML, but after a while ( this time takes longer ) i determine again I should change something again ! So I get back and change my UML( sometimes not ! just continue the project without changing UML ) and so on. This process will happen over and over until I become tired or find (almost) the best state of the project or have time limitation problem! So my question is:   * _'Can I design a perfect UML at the beginning of my project so that describe the best state ever !?'_ or _\- 'Should I swear in God never ever change my UML ( and project definition ) even if there is a better one and write current state to the end!'_ Another question "Is changing some parts of a new idea, even if analyzed with hands of the best analyzer in the world, is inevitable ?( in order to find the best state )". I mean we can't fully simulate user experience, can we? We should see it in action.


Choosing how to approach Geocoding Requests

I am about to begin writing a program in c# that will read Addresses from a source file create a Geocoding request, sent it to Google Maps API, get the response choose the coordinates from the xml and then store them in a database. My question is what is the proper type of source file considering performance and easy implementation. I have the option to supply the source addresses as txt file or xml file. The number of addresses need to get geolocated is about 100.000 which is a big number so what is the proper approach to handling this kind of requests? Should i provide the addresses source file as txt or xml or something else?


How to keep unit tests independent?

I've read it at many places that unit tests should be independent. In my case I have a class that does data transformation. These steps must be done sequentially, otherwise they don't make sense. For example,               load_data     parse_float     label     normalize     add_bias     save_data      For example, I cannot normalize the data before I label it, because then values have changed and I don't have access to the original values of my data anymore. Or I cannot save the data before I actually loaded it. So my test class looks something like this               class TestTransform(Testcase):       def setUp(self):         self.trans = Transform()            def test_main():         self.load()         self.parse_float()         self.label()            def load(self):         self.trans.load()         assert ....            def parse_float(self):         self.trans.parse_float()         assert ....      In this case, my unit tests clearly depend on each other, but I can't see how else I could do it. As an alternative, I could write something like this                 def test_normalize(self):         # setup         self.trans.load()         self.trans.parse_float()         self.trans.label()         # test begins here         self.trans.normalize()         assert ....      But in this case, I run a lot of code multiple times, which is inefficient and makes my tests run a lot longer. So does the best practice of keeping unittests independent apply in this case or not?


Best way to create draw with limitation

I'm writing a program to automatically make the draw for a competition. There are four objects: `Debate` `Judge` `School` `Team` Each Debate has two teams and a judge. Each team participates in three debates. With this, there are the following rules: 1) A team cannot face someone from their same school 2) A team cannot face another team from the same other school (As in if they play a team from a school once, they cannot play again against someone from that school) 3) A judge cannot come from the same school as a team they are judging. So how would I create a draw? A draw looks like a table (I just need the data, but when you write it it looks like this) with a column for judges and then three other columns for each round of debates (the three debates each team participates in). Right now I'm basically choosing a random team, finding an opposing team that hasn't played the school of the first team before and doesn't come from the same school and then finding a judge from neither of those schools. Then I do the same thing until I have all the debates. The problem is the program sometimes gets into ruts where there is no other team/judge that fits. A human would then shift things around and try to find a way to move other judges around to figure it out, but how can I do that with a program. If I run the program again it figures it out just because it's random which teams it chooses for what. Basically, I'm wondering what the best solution is to the problem?


How to reduce the number of bugs when coding?

No one's perfect, and no matter what we do, we are going to produce code that has bugs in it from time to time. What are some methods/techniques for reducing the number of bugs you produce, both when writing new software and changing/maintaining existing code?


How to be more logical? (less bugs/errors)

I have been programming for 6 years and I am in high school (I prefer not to disclose my age). I have dabbled in many different languages. Just to list a few: Java, PHP, C++, Python, Autohotkey, Mathematica and many more. I have a very good understanding of the basics of general programming. The only problem is I _still_ create bugs all the time. I think too often. Do you have any hints _besides continuing_ to program that will help me become a better programmer and make less errors?


How to make code writing more accurate?

I am trying to practice writing code for a long period of time before compiling and write unit test (if possible) for what I wrote (the language is C++). Of course, I got the IDE support (Emacs or Eclipse for on the fly error detection and code completion) with minimal or no error. I practice this ability because the pattern "trial and error" in which a bit of code is written and then build/run to check the correctness is not productive as I feel. However, isn't what I am doing counter the purpose of testing? Maybe, the point of my practice is not to assure 100% logic correctness, but rather, 100% or close to 100% syntax correctness, in order to vastly improve productivity. I will try to practice with the small piece of code first, and then improve gradually as time passes. What's your opinion on code writing and productivity in general? Do you practice like I do or do you have much better method? (Aside from being in the "flow", or extremely concentration). I concern this matter because I heard that some people are an actual human compiler, and it seems like they can directly translate the logic to code as their natural language. **Edit:** I was a bit wrong when I mentioned not to improve logical correctness. Yes, logical correctness counts as well. What I want is to practice programming to the point where I can keep writing code for a long period of time with minimal mistakes (such as I can write 1000 lines of code,a and only a few trivial errors occur).In case of C++ or any language, using external libraries require you to understand many dependencies of the libraries to use it correctly in your code. For example, if you use Spring framework in Java, you have to make sure the xml, the server etc... are set up correctly. I consider this is also a form of syntax, and one way to achieve "syntax correctness" is to practice it frequently to the point when you can minimize the most mistakes written by hands. This is similar to when we first start learning programming, sometimes/often we miss the semicolon. Then we learn the mistake and improve it.


How do you stop yourself from making mistakes?

I used to pride myself with the high quality of the code I delivered. Today I made a mistake that wiped the grin off my face. It was a null reference exception caused by a hasty fix to an edge case that was caught during testing. I didn't have proper unit tests and I didn't regression test after making the fix. So my question is, what do you do to force yourself to follow best practices? I know you should write tests (unit, integration, acceptance, etc.) and run them to validate any changes. But when the pressure's on and you're rushing to put out a fire, how do you keep yourself focused and sticking to those best practices? Physical exercise? Religious TDD?


How can I learn to like C++?

I'm a wimpy web programmer by trade -- I enjoy programming in JavaScript, CoffeeScript, TypeScript, and Ruby. I have to program in C++ for my computer science degree, and it frustrates me. I don't much like the syntax and I feel that it's more verbose than it could be. I think I've roared "I hate C++" at least once per CS project. I don't need to _love_ C++, but I wonder if someone who adores the language can tell me what I can do to ease my pain. C++11 and Syntastic for Vim have certainly helped, but I'm wondering if there's something more than that -- a specific tool or an abstract philosophy.


Have you tried Usability Audit for your company's website?

We had a security audit and it was brilliant. Are there companies that do web usability audit?


Are there any studies of cross-functional teams vs. domain-based teams (e.g. project-based vs. software/mechanics/etc)?

I work in an organization which creates many integrated systems products - i.e. it is complete products with mechanical/system/electronics/software being designed and manufactured. At the moment most teams are organized around projects in a cross functional way. The advantage of an organization like this is that people who are working closely together for a common goal are close. The disadvantages come from the isolation of engineers from their peers. Typically a project is assigned only one software engineer. This means that the projects have a high truck factor, minimal knowledge sharing and best practices, and technical development is limited. So my question is: are there any studies comparing the cost/benefits of these two approaches?


Is it legal to disassemble a Microsoft dll and post the result on my blog?

I'm writing an article for my blog about undocumented functions which exist in the _dwmapi.dll_ library. I want to post the result of the disassembled code to explain how the names and parameters of these functions are obtained, something like the article from this blog. **This is only for educational purposes** to show a couple of samples using these undocumented functions. So the question is: _Can I post the disassembled code of this library on my blog?_ **UPDATE :** There exist a couple of applications like Aura which uses these undocumented functions (DwmGetColorizationParameters, DwmSetColorizationParameters), obviously the authors in some point disassembled the _dwmapi.dll_ file in order to get the parameters and functions names. But they (the authors) only publish the final source code to access to these functions. This makes me think that _I can disassemble in private a Microsoft dll and then publish an application or source code based in this research_. Is this correct?


Why do some of object oriented languages let programmer use primitive types?

Why do some object oriented languages let the programmer use primitive data types? Aren't classes like Integer, Boolean, etc. enough?


Job in other country - relocation package

I have the opportunity to work in an 'overseas' country. I have passed the technical interviews and I am at the 'offer' stage. Everything is ok, except for the fact that I am expected to pay for my plane ticket, which is almost 2000 EUR (an aprox 8000 km distance). I've discussed this with the possible future employer and they said that the plane ticket is my expense. What I'm asking you is: Shouldn't they pay me for the plane ticket? Or give me a relocation package? Do you accept this kind of offer? What relocation package would you have asked for if you were in my shoes? PS: Destionation country is Singapore. I am a Delphi Developer with 5 years of experience in SD, and overall 8 years in IT.


Good Version Control Guidelines from a Development/Collaboration Perspective?

At our company we have started outsourcing some of our development. This has worked somewhat well. However, we are having a hard time getting them to properly use version control. They are familiar with SVN and know how to use it. However, for some reason they don't commit regularly, instead they work with 16 things simultaneously and make a huge commits every 2 weeks, if we are lucky maybe with a few comments. Which makes it very difficult to both following and review their work, collaborate and also fix bugs. I have tried to explain to them to do their work as one small task at a time and regularly commit each of these with appropriate comments. Without much success, either they don't understand the concept or they are lazy. My question is, what would be good guidelines describing how one should work with version control, not from a technical perspective (they know SVN), which seems to be the only thing I'm finding online, but from a development/collaboration/project perspective?


call a function and never wait for it in C#

I have a controller in my mvc4 web application in which there is an action that needs to call another function. What happens in that function i.e. the return value is not important for my action. How i can call that function and never wait for it to be executed? I think it can be done by async but my point is not to use resources, just call the function and never wait for it what ever happens. Please give me some advise.


Looking for a digital developer book service

I just started managing a small team of developers for my company and I would like to give them access to a library of books that would help them improve their skills. Before I buy a bookshelf worth of books I was wondering if anyone was aware of any services that would fill this need. Something that anyone with an account could log into and get access to the latest books on programming and software development. Ideally, something like a shared kindle account, but would be happy to hear about other experiences or ideas that would also help fit my need. Or even if you think I am dreaming and should just shell out some money for the books.


Where should I include comments in my "self-documenting code"?

I'm currently developing a web-app by myself and have made it a point to use descriptive variable and method names (sometimes at the expense of brevity) in order to minimize commenting. The plan was to code each method using this strategy, then comment after I've completed the method I was currently working on. However, I've found that after (more or less) all of the methods I've completed, in-line comments seemed superfluous. I still follow Javadoc conventions for classes and methods, but as of now my code is for the most part, completely devoid of any in-line comments. Fortunately, I'm still relatively early in the development process and all of the methods' workings are fresh in my head, should a situation arise where I need to write in-line comments. Is this a good strategy? If not, where should I include in-line comments? I've included one of my methods below in order to illustrate how self-documenting it currently is. (I'm using Pelops, which is a Java library used to access a Cassandra database. Without going in too deep in to Cassandra's data model, a row basically corresponds to a relational database tuple, and a column corresponds a column in a relation database table). I'd like to think that even without knowledge of Pelops or Cassandra, that one will be able to understand what is going on in the code. Is this the case? If not, where can I insert comments to make it crystal clear? I hope to abstract any suggestions on comment placement in this code in to all the other methods I've written so far.               /**          * Gathers a user's ID and first name from the database, creates a random activation code for that user and stores          * it in the database, and sends an activation e-mail to that user.               * @param eMail                           a String representation of the e-mail of the user that the e-mail is being sent for          * @throws MyAppConnectionException      if any of the queries is unable to be executed or a problem arises because of one, or if a problem arises while sending the e-mail          */         public static void generateAndSendActivation(String eMail) throws MyAppConnectionException, MyAppActivationException         {             eMail = eMail.toLowerCase();                  try             {                 Selector userIDSelector = Pelops.createSelector(pool);                 Column userIDColumn = userIDSelector.getColumnFromRow("Users_By_Email", eMail, "User_ID", ConsistencyLevel.ONE);                 String userIDString = new String(userIDColumn.getValue());                      Selector firstNameAndStatusSelector = Pelops.createSelector(pool);                 SlicePredicate firstNameAndStatus = Selector.newColumnsPredicate("First_Name", "Status");                 List<Column> firstNameAndStatusColumns = firstNameAndStatusSelector.getColumnsFromRow("Users", userIDString, firstNameAndStatus, ConsistencyLevel.ONE);                      char statusChar = Selector.getColumnValue(firstNameAndStatusColumns, "Status").toChar();                      if(statusChar == 'N')                 {                     String firstNameString = Selector.getColumnStringValue(firstNameAndStatusColumns, "First_Name");                          String activationCode = createRandomCode();                     String activationHash = BCrypt.hashpw(activationCode, BCrypt.gensalt());                          Mutator storeActivationHashMutator = Pelops.createMutator(pool);                     storeActivationHashMutator.writeColumn("Users", userIDString,                             storeActivationHashMutator.newColumn("Activation_Code", activationHash)                             );                          storeActivationHashMutator.execute(ConsistencyLevel.ONE);                     sendEmail(firstNameString, userIDString, eMail, activationCode, "sendActivationCode");                 }                 else                 {                     throw new MyAppActivationException("User with ID " + userIDString + "tried to activate an already activated account");                 }                  }             catch(NotFoundException nfe)             {                 MyAppQueryException bqe = new MyAppQueryException("Account for user with e-mail " + eMail + " not found. Cannot send activation code", nfe);                 bqe.accountDoesNotExist = true;                 throw bqe;             }             catch(PelopsException pe)             {                 MyAppQueryException be = new MyAppQueryException("Unable to carry out one of the operations required to generate and store activation code", pe);                 throw be;             }             catch(MyAppMailException bme)             {                 throw bme;             }         }


Does directly accessing an applications database break the license agreement?

We have purchased a fairly light-weight application that uses a database on SQL Server for its back-end. This application has no API. There is a small web-based feature we need to add, that can easily be added by connecting to the database directly. **Generally speaking, and all issues relating to future schema changes aside, is this typically allowed by the software license?** A co-worker made the argument that in the spirit of the software license, we are reverse-engineering their code. I hold the belief that it is our data in the database that we would be accessing and potentially modifying, no license is required for the actual data. In addition, since we still pay for a license to use the software, that means we also have a license to use its schema, as the schema is part of the software. It is also my understanding that it is common practice (at least, everywhere I have worked) to access an application's database directly for reporting purposes. Which is considered correct? I am interested in input from both a legal standpoint, and an industry commonly understood standpoint. _I also understand that this will vary from license to license. I am looking for a general answer that will apply to most software. Thank you._ * * * **Edit:** Perhaps another way to look at it... What is generally considered acceptable? Throw out the license agreement, since the legal question cannot be properly answered without the license. **As a developer, would you be unhappy with your users accessing the database directly?**


What's the best Java equivalent to Linq?

Are there any libraries in Java that come close to providing the functionality of Linq?


How can I get my startup working with Agile development?

In our startup, we've worked until now using the traditional waterfall model, but we want to try our next project using Agile Methodology. We are pretty much alien to the entire Agile process, so considering this, what is the best way to understand Agile (resources and a practical handbook can be of help), decide on a specific methodology (Scrum, etc), and start it in our next project?


Which methods should be put in an interface and which in abstract classes?

I have seen many frameworks and modules and their standard they follow is like this   1. `UserInterface` which have some predefined methods   2. `AbstractUserClass` which implements `userInterface`   3. Then `GenericUserClass` which extends from `AbstractuserClass`   4. Then other classes extending from that generic Now I have seen that abstract class has additional functions to the interface, and the generic class also has additional functions.   1. So I am confused which methods should go where   2. Sometimes I see `class A extends Abstractuserclass` and sometimes `class A extends Abstractuserclass implements UseraInterface`. What is the difference if `Abstractclass` already impelements `Userinterface`


Which professional positions combine Computer Science and Marketing?

I would like to find a job that combines Computer Science with Marketing, ideally in a position where you get to meet a lot of people and travel a fair bit. After having worked as a Front/Back Web App Developer I am getting a degree in Management of Technology, which also includes an element of Marketing. How can I combine my two interests, Computer Science and Marketing, professionally, in a sensible way? Which positions should I be aiming for?


What is a buffered write scheme?

I received this response from Jeff while researching hit counters. He said page hits are incremented in a `buffered write scheme,` and that a views table does not exist. Can you explain what a buffered write scheme is, please? I would appreciate answers not too heavy with technical jargon. In particular I'm interested in how such a scheme can be implemented to track page hits. I'm curious how hit data gets persisted since it is needed to prevent users from simply refreshing a page to increment page hits.


Am I a bad programmer, or does everyone have this feeling?

I tend to understand things rather quickly, but after 2 years of programming in Python I still stumble across things (like Flask today) that amaze me. I look at the code, have no idea what's going on, and then feel very humbled. I feel like an absolute expert each time this happens, up until the moment it happens. Then, for about a 2 week period I feel like an absolute beginner. Does this often happen, or does it indicated that I have so much more to learn before I can even be considered a "good" programmer?


Nested Classes or Namespace

Why do need namespaces when we have nested classes. What can be done through namespaces, can also achieved through nested classes. so I don't understand the reasoning of having namespaces ?


How to separate sensitive data in database(MySql)

I need to design a database that will contains information about personal disease of users. What can be the approach in order to implement the columns of the DB's tables: encrypt the information, separate data within two differents DB, one for sensitive data and another for not sensitive data, or both or another approach?


Do you also forget the code after getting the task done?

I'm a new programmer and want to ask senior programmers (programmers who have some experience in the real world). I do my work and after coding, my project gets completed but honestly speaking I don't remember the code, classes and frameworks name and their properties. Sometimes even I doubt myself that did I made this? Is this normal with all programmers or am I the silliest programmer who couldn't remember the code and classes/properties names? **Edit:** I think many of programmers are getting me wrong here. I said I forget frameworks names, classes' names, property names but I start remembering my own code once I start working on it again. My question is do you remember syntax and classes/property etc. names?


How to correct a junior, but encourage him to think for himself?

I am the lead of a small team where everyone has less than a year of software development experience. I wouldn't by any means call myself a software guru, but I have learned a few things in the few years that I've been writing software. When we do code reviews I do a fair bit of teaching and correcting mistakes. I will say things like "This is overly complex and convoluted, and here's why," or "What do you think about moving this method into a separate class?" I am extra careful to communicate that if they have questions or dissenting opinions, that's ok and we need to discuss. Every time I correct someone, I ask "What do you think?" or something similar. However they rarely if ever disagree or ask why. And lately I've been noticing more blatant signs that they are blindly agreeing with my statements and not forming opinions of their own. I need a team who can learn to do things right autonomously, not just follow instructions. How does one correct a junior developer, but still encourage him to think for himself? Edit: Here's an example of one of these obvious signs that they're not forming their own opinions: > Me: I like your idea of creating an extension method, but I don't like how > you passed a large complex lambda as a parameter. The lambda forces others > to know too much about the method's implementation. > > Junior (after misunderstanding me): Yes, I totally agree. We should not use > extension methods here because they force other developers to know too much > about the implementation. There was a misunderstanding, and that has been dealt with. But there was not even an OUNCE of logic in his statement! He thought he was regurgitating my logic back to me, thinking it would make sense when really he had no clue why he was saying it.


Selecting the main version of a linux library

I am looking to use cracklib library for testing password security in my C/C++ linux applications. But I cannot find the original author, nor the official code that hasn't been forked.


GPL - Writing an exception for a plugin interface under section 7 of GPLv3

## The problem I've written a application for Android licensed under GPLv3 which needs to use Google Play Services, a proprietary library, as a plugin to the app. Now I'd also like to add libspotify as a plugin. For all of the proprietary libraries used I'm providing alternative open source plugins but they are not as good as the proprietary ones, not even close. The user should then be free to disable all proprietary parts either at compile or runtime. ## Possible solutions The GPLv3 has a section "7. Additional Terms." under which you can add a "classpath" exception. I'd like to use this exception to do the following. The idea of a classpath exception is explained in the GPLv3 FAQ here:   * Linking over a controlled interface: http://www.gnu.org/licenses/gpl-faq.html#LinkingOverControlledInterface   * http://www.gnu.org/licenses/gpl-faq.html#GPLIncompatibleLibs ## The basic idea Implement these interfaces:               interface Plugin {}          interface ProprietaryPlugin extends Plugin {}          interface XYZ_1 extends Plugin {         public void someHook();         public void someOtherHook();         ...     }          interface XYZ_2 extends Plugin {         public void someHook();         public void someOtherHook();         ...     }          XYZ_3, 4, ...      The above interfaces are part of the project and are under GPL. But I'd like to let all code that extend some subinterface of Plugin except ProprietaryPlugin to be able/allowed to be proprietary given that they mark themselves as ProprietaryPlugin. My intention is to make tight plugin hooks that all proprietary plugins must follow and a way to indicate to the user which plugins that we can remove at runtime. Also, I want the "bridge" code, the implementation of the plugin interfaces to be open source and under a GPLv3 compatible license. And the source code must provide at least one GPLv3 implementation, hopefully creating a concrete wall between the GPLv3 and proprietary code. ## Visual explanation ![visual explanation with UML and licenses](http://i.stack.imgur.com/NmkP5.png) Is this possible to do? I know that most guys here are not lawyers, but I find asking developers first enlightening. ## A suggestion from irc.gnu.org#gnu The guys at irc.gnu.org#gnu gave me the following suggestion: https://raw.github.com/qcad/qcad/master/gpl-3.0-exceptions.txt It states that:               As a special exception, the copyright holders of QCAD hereby grant permission      for non-GPL compatible plug-ins and script add-ons to be used and distributed      together with QCAD, provided that you also meet the terms and conditions of the      licenses of those plug-ins and script add-ons.      Is "non-GPL compatible plug-ins and script add-ons" vague / a loophole, or is it clear and does it apply to my case? ## A second suggestion I got a second suggestion at #gnu: http://roundcube.net/license/ It states that:               This file forms part of the Roundcube Webmail Software for     which the following exception is added:      Plug-ins and Skins which merely make function calls to the Roundcube Webmail Software,     and for that purpose include it by reference shall not be     considered modifications of the software.          If you wish to use this file in another project or create a modified version that will      not be part of the Roundcube Webmail Software, you may remove the exception above and      use this source code under the original version of the license.       What do you think about this one? ## My attempt at a "classpath exception" My first idea was to add the classpath-exception to Plugin with something like the following... does it accomplish my intent or is it filled with loopholes, etc.?               Additional permission under GNU GPL version 3 section 7          0. Definitions          "FSF" means the Free Software Foundation, Inc.          "Compatible License" means any license the FSF      considers to be compatible with the GNU GPL version 3.          "Plugin interface" means any interface definition file in the Corresponding Source     containing - in the file's header - the words      "The licensors of this Program designates this particular file as a Plugin interface"          "Proprietary interface mark" means any interface definition file in the Corresponding Source     containing - in the file's header - the words      "The licensors of this Program designates this particular file as a Proprietary interface mark""          "Allowed library" means any library that is linked or combined with this Program,      or any covered work that creates a derivative work of a      subinterface of a Plugin interface not directly linking with the library.     Such a subinterface provides at least the source code      of one working implementation licensed under This License.     The derivative work of the subinterface linking to the      Allowed library implements a Proprietary interface mark.     Such a derivative work is referred to as a "Proprietary plugin implementation".     A Proprietary plugin implementation is licensed under a Compatible License.          1. Exceptions          If you modify this Program, or any covered work, by linking or combining it      with any Allowed library (or a modified version of those libraries),     containing parts covered by the terms of those libraries, the licensors of this      Program grant you additional permission to convey the resulting work.     {Corresponding Source for a non-source form of such a combination shall include      the source code for the parts of any Proprietary plugin implementation     used as well as that of the covered work.}


What are tangible advantages to proper Unit Tests over Functional Test called unit tests

A project I am working on has a bunch of legacy tests that were not properly mocked out. Because of this the only dependency it has is EasyMock, which doesn't support statics, constructors with arguments, etc. The tests instead rely on database connections and such to "run" the tests. Adding powermock to handle these cases is being shot down as cost prohibitive due to the need to upgrade the existing project to support it (Another discussion). My questions are, what are the REAL world tangible benifits of proper unit testing I can use to push back? Are there any? Am I just being a stickler by saying that bad unit tests (even if they work) are bad? Is code coverage just as effective?


PHP best practice in return values

For PHP, best practices, I have read somewhere that if you assign your data to a variable it takes almost no memory or resource. So let's say I have this function that return a count.               public function returnCount($array){         return count($array);     }      or if this is better?               public function returnCount($array){         $count = count($array);         return $count;     }


Find a "hole" in a list of numbers

What is the fastest way to find the first (smallest) integer that doesn't exist in a given list of **unsorted** integers (and that is greater than the list's smallest value)? My primitive approach is sorting them and stepping through the list, is there a better way?


Guidance in naming awkward domain-specific objects?

I'm modeling a chemical system, and I'm having problems with naming my elements / items within an enum. I'm not sure if I should use:   * the atomic formula   * the chemical name   * an abbreviated chemical name. For example, sulfuric acid is H2SO4 and hydrochloric acid is HCl. With those two, I would probably just use the atomic formula as they are reasonably common. However, I have others like sodium hexafluorosilicate which is Na2SiF6. In that example, the atomic formula isn't as obvious (to me) but the chemical name is hideously long: `myEnum.SodiumHexaFluoroSilicate`. I'm not sure how I would be able to safely come up with an abbreviated chemical name that would have a consistent naming pattern. There are a few problems that I'm trying to address through naming the enum elements.   The first is readability, with the longer names presenting an issue.   The second is ease of picking up the code for new maintainers, and here the shorter names present an issue.   The next issue is the that business owners usually refer to the full chemical name, but not always. The "mouthful" chemicals are referred to by their formula.   The final concern is making sure it's consistent. I _don't_ wan't a mixed naming convention as it will be impossible to remember which to use. **From a maintenance point of view, which of the naming options above would you prefer to see and why?** * * * _Note: Everything here below the line is supplementary | clarifying material. Please don't get bogged down in it. The main question regards naming the awkward objects._ _Atomic Option_               public myEnum.ChemTypes     {          H2SO4,        HCl,        Na2SiF6     }      _Chemical Name Option_               public myEnum.ChemTypes     {        SulfuricAcid,        HydrochloricAcid,        SodiumHexafluorosilicate       }      * * * Here are some additional details from the comments on this question:   * Audience for the code will be just programmers, **not** chemists.    * I'm using C#, but I think this question is more interesting when ignoring the implementation language.   * I'm starting with 10 - 20 compounds and would have at most 100 compounds, so I don't need to worry about _every_ possible compound. Fortunately, it's a fixed domain.   * The enum is used as a key for lookups to facilitate common / generic chemical calculations - which means that the equation is the same for all compounds but you insert a property of the compound to complete the equation.     * For example, Molar mass (in g/mol) is used when calculating the number of moles from a mass (in grams) of the compound. FWIW, Molar Mass == Molar Weight.      * Another example of a common calculation is the Ideal Gas Law and its use of the Specific Gas Constant A sample function might look like:               public double GetMolesFromMass(double mass_grams, myEnum.ChemTypes chem)     {       double molarWeight = MolarWeightLookupFunctionByChem(chem); //returns grams / mole       double moles = mass / molarWeight;  //converts to moles            return moles;     }          //Sample Call:     myMoles = GetMolesFromMass(1000, myEnum.ChemTypes.Na2SiF6);     //*or*     myMoles = GetMolesFromMass(1000, myEnum.ChemTypes.SodiumHexafluorosilicate);                    public double GetSpecificGravity(myEnum.ChemTypes chem, double conc)     {       //retrieves specific gravity of chemical compound based upon concentration       double sg = SpecificGravityLookupTableByChem(chem, conc);       }      So the enum of the compound name is used as a key and to provide consistency in referencing the compound with the related functions.


Patterns for ajax-heavy web applications

Up until now, I've been a great fan of the MVC pattern for developing web applications. For the web, I've developed mostly in PHP (with the Kohana and CodeIgniter frameworks) and Ruby (RoR). As my applications become heavier on the Ajax side (single-page apps etc) I noticed that I can't help but betray the very basic concepts of MVC: Javascript is doing most of the works; calling controllers just to ask for views or more js/json code seems wrong. After striving for keeping all the routing jobs in the controllers, now I've fundamentally split it between them and Javascript (that is, from the framework's PoV, part of the views). When asking for json the MVC subversion looks even more obvious: the js code doing the request _is_ the controller; the framework's controller is merely acting as proxy for the model's data - what I'm actually asking for. So, what should I look into? I was thinking about pure-javascript applications, for instance with backbone.js and a document-based, json-spitting database (couchDB) as backend, but I love my relational databases. Another option would be the following: I'd just make "routed models" in PHP/ruby/go/whatnot. Those will analyse the request, call the db, give back some json. This approach looks interesting to me but it lacks any substantial documentation or academic analysis, so I'm a little afraid of the leap. Ideas?


Where and how to mention Stackoverflow participation in the résumé?

I think I have good enough reputation on SO now. Well, this may not be that much as compared to so many other users out there but I am happy with mine. So, I was thinking of adding my profile link on my résumé - just the profile link and not that "I have this much reputation on SO". Those who haven't seen, can see this question Would you put your stackoverflow profile link on your CV / Resume? How would this look like? > **Forums/Blogs/Miscellaneous others** > > No blogging as yet but active participant in Stackoverflow. My profile link > - `http://stackoverflow.com/users/userId/username` I think of putting this section after **Project Details** and **Technical Expertise** sections. Any tips/advice? **Update** MKO has made a very good point \- > do you really want a potential employer to be able to evaluate in detail > everything you've ever written on SO I thought of commenting but it would be too long -   In my questions/answers I put a lot of statements like - "AFAIK ...", "following are my assumptions so far ...", "am I correct to conclude that... ?", "I doubt if it is possible to ..." etc. when I am not sure about something and I rarely involve in fights with other users. However I do argue on topics sometimes if I feel it is necessary and if I have a valid point. I do accept my mistakes and apologize for the same. As we all know nobody is perfect. I must have written many things which may be judged as wrong by a potential employer. But what if the same employer notices that I have improved in the quality of content by comparing old content with new one? Isn't that great? I also try to go back to older questions/answers and put corrective comments etc. when I feel I was wrong or if I can improve my post. Of course there are many employers who want you (potential employees) to be correct each and every time. They immediately remove you from consideration when you say a single incorrect thing. I have personally met such an interviewer few months back. He didn't even care to listen to any good thing I had done after he found a single wrong thing. Now the question is do you really care to work with such people? Or do you like those people who give value to the fact that you are striving to improve every day. I personally prefer the latter.


Learning in the Classroom

I am currently taking an Assembly programming class, and I honestly find it extremely boring and tedious. While I've programmed some assembly before as part of a C++ program, I find what we are doing to be completely different than actual assembly code I've worked with (we are using a program called MARS MIPS, found here). Since we are using the MIPS architecture, which from what I gathered is hardly used any more, I find what we are learning hardly applicable to anything outside of the class. Likewise, I find myself not retaining the material we cover in class due to detachment from real world applications as well as the classroom setting itself. I've been trying to write my some code outside of the classroom to get familiar with it, but without any obvious real world applications, I find myself unmotivated to do so. **Is there any advice for trying to learn a programming language (such as assembly) for a class when I don't seen any real world application of it?** Or perhaps a more specific question to this problem would be: **Is there any real world application to the MIPS architecture which I am unaware of?** **EDIT:** I found the following information on StackOverflow concerning MIPS: http://stackoverflow.com/questions/2635086/mips-processors-are-they-still-in- use-which-other-architecture-should-i-learn


What is the alternative to frequent manual verification?

I was thinking, is there a particular time in your coding where you verify that it works? Say, after coding a function, or an entire class, or an entire section of an app, or after every 'significant' block of code? I ask this, because I tend to verify my app too often, sometimes after every 3rd or 4th change. This is a habit which has proven very hard to shake. It appears to be counter productive to do this repeatedly and manually. Is there another solution? It seems to be either be a more competent programmer and essentially 'know' the return of the majority of your code, or have your IDE check the return periodically, or only test the return via TDD.


How should a ViewModel be named?

While starting work on a brand new ASP.net MVC application we've learned that we should have all of our available data pushed to make it easy to create a full view. While learning this we've started using a concept of a ViewModel, or a complex object full of properties from other basic data transfer objects. Now our problem has been in naming these ViewModels. We've run across the idea of using a name created from the DTO object names like MemberContactViewModel. while this is okay, I feel that names should be more unique or more related to what the complex object will be doing rather than what it's made up of. What are your thoughts. How should a complex ViewModel be named, based on the data it holds, or the view where it will interact with. Thanks for the input.


Where can I turn to if I can't fix a bug?

I am looking for resources to turn to when I don't have the answer for something. I lead a team of software developers. We have been rolling out new software releases on a monthly basis. When there is a bug that my team cannot fix, it lands on me. Most of the time I can resolve the issue, but there are times when I get stuck. Unfortunately, I'm the top of the line at our company. There is nobody I can ask for help or assistance in figuring something out. Do you happen to have any recommendations or guidance for situations like this?


Git submodule vs Git clone

I am working on an opensource project on github. It has a subdirectory /Vendor in which it has a **copy** of several external libraries. Original maintainer of the project updated this directory with newer copy of external library once in a while. One developer send me a pull request with idea to replace this **copy** by **git submodule**. And I am considering whether it's good idea or now. Git submodule Pros:   * Submodules were specifically designed for similar scenarios   * It removes possibility of accidental commit to Vendor which will be overwritten while next update Git submodule Cons:   * It looks like git submodules pushes complexity from maintainer to a person who will clone/pull the project (additional steps required after you clone to start working with the project: "git submodule init", "git submodule update" What's your opinion on this? One more thing. This problem is reasonably small size library with very limited external dependencies. I think any build tool would be overkill for it for now.


Personal Software Process (PSP1)

I'm trying to figure out an exercise but it doesn't really makes to much sense.. I'm not asking someone to provide the solution. just to try and analyse what needs to be done in order to solve this. I'm trying to understand which PSP 1.0 1.1 process I should use. PROBE? Or something else? I would greatly appreciate some help on this one from someone that has experience with the Personal Software Process Methodology.. Here is the question. > For the reference case (“code1.c”), the following s/w metrics are provided: > >   * man-hours spent in implementation phase (per-module): 2,7 mh/file >   * man-hours spent in testing phase (per-module): 4,3 mh/file >   * estimated number of bugs remaining (per-module): 0,3 errors/function, 4 > errors/module (remaining) > > > Based on the corresponding values provided for the reference case, each of > the following tasks focus on some s/w metrics to be estimated for the test > case (“code2.c”): [25 marks] > >   1. (estimated) man-hours required in implementation phase (per-module) [8 > marks] >   2. (estimated) man-hours required in testing phase (per-module) [8 marks] >   3. (estimated) number of bugs remaining at the end of testing phase (per- > module) [9 marks] > > > Tasks 4 through 6 should use the data provided for the reference case within > the context of Personal Software Process level-1 (PSP-1), using them as a > single-point historic data log. Specifically, the same s/w metrics are to be > estimated for the test case (“code2.c”), using PSP as the basic estimation > model. > > In order to perform the above listed tasks, students are advised to consider > all phases of the PSP software development process, especially at levels > PSP0 and PSP1. Both cases are to be treated as separate case-studies in the > context of classic s/w development.


Visual web page designer for Django?

I'm just starting my Django learning so pardon me if any part of this question is off-base. I have done a lot of web searching for information on the equivalent of a visual web page designer for Django and I don't seem to be getting very far. I have experience with Delphi (Object Pascal), C, C++, Python, PHP, Java, and Javascript and have created and maintained several web sites that included MySQL database dependent content. For the longest time I've been using one of the standard WYSIWIG designers to design the actual web pages, with any needed back end programming done via Forms or AJAX calls that call server side PHP scripts. I have grown tired of the quirks, bugs, and other annoyances associated with the program. Also, I find myself hungry for the functionality and reliability a good MVC based framework would provide me so I could really express myself with custom code easily. So I am turning to Django/Python. However, I'm still a junkie for a good WYSIWIG designer for the layout of web pages. I know there are some out there that thrive on opening up a text editor, possibly with some code editor tools to assist, and pounding out pages. But I do adore a drag and drop editor for simple page layout, especially for things like embedded images, tables, buttons, etc. I found a few open source projects on GitHub but they seem to be focused on HTML web forms, not a generic web page editor. So can I get what I want here? The supreme goal would be to find not only a web page editor that creates Django compatible web pages, but if I dare say it, have a design editor that could add Python code stubs to various page elements in the style of the Delph/VCL or VB design editors. Note, I also have the Wing IDE Professional IDE, version 2.0. As a side note, if you know of any really cool, fun, or time-saving Python libraries that are designed for easy integration into Django please tell me about them. \-- roschler


REPL - Do You Find It Useful?

Recently I started learning Clojure and downloaded Clojure-Box for Windows which came with SLIME and have been fiddling around with Clojure using the REPL mode. Now, I have starting learning many languages that have REPL available (F#, Python, Haskell) but have never used it until I started with Clojure and I realized how much of a help it is. I was wondering how many people use REPL for the languages that have them available. If you don't use them, what is your reasoning not to? If you do use them, do you use them for testing code or just for learning languages?


How to set up Unit Testing in Visual Studio 2010?

I'm doing my first big project and I don't have a lot of experience in a professional programming environment. While researching anything programming- related I often see references to Unit Testing, but I am still unclear as to how to set those up or even if it would be beneficial to me. Can someone explain unit testing to me, and how to set it up in a Visual Studio 2010 solution that has multiple projects? Is it something that occurs within your project's solution, or is it a separate solution? And is it something you'd recommend for a small development team or is it just a waste of time to setup? Right now I just run the entire program to test whatever I am currently working on, but occasionally I have run into problems that are not easy to debug and it would be useful to run subsets of the code elsewhere... Sometimes I do setup another project with some of the libraries referenced to test a small part of the program, but I feel more time is wasted setting that up then just running the entire program because of all the dependencies involved


When would someone be considered a bad programmer?

How would you consider that a programmer is bad at what he or she is doing? If possible... How should he/she improve?


Scrum in a consulting environment?

Is it possible to introduce scrum to a consulting environment? On any given week I might belong to 4 different teams, each with a different PM, BA and dev team (I am a designer). It doesn't seem feasible, time wise, to be able to be part of that many teams/projects as there would need to be daily stand-ups for each, sprint reviews, etc. I should add these projects are not necessarily software, but mainly ecommerce web projects. Can someone who has done this speak to how you approach it? _Edit_ I think my situation is different and I should have discussed it further. Our dev team is in India, so finding a time in the US morning/India evening for daily stand-ups are hard, especially when we almost always have client calls in the US morning/India evening so dev can be present if necessary. Instead, what our PM's have done is have 1 daily meeting for the US team (BA, Design). However, they go through ALL the projects at once. So, if you're not on that project, you're screwed and have to wait till your project comes up. This can be 30min-75min a day, for me. Insane. This does NOT cancel our weekly status call (30m-1h) with the client (x however many projects you are on). This is obviously not scrum, as there are no devs present during any of this and it's just action items being listed for the US team. However, I'd love to get to a point where our 'scrum-like' dev team (they develop in sprints and have sprint planning meetings) can be part of daily standups with the US team and we transition to an actual scrum framework.


Why the ugly keywords in C11?

I am currently reading a draft of the C11 specification. The new introduced keywords: `_Bool, _Alignof, _Atomic` all feel like custom extensions, instead of standard reserved keywords like `struct, union, int`. I realize that the standard basically consists of standardized extensions ... but still, this is awful! Maybe we will soon end up with `__Long_Long_Reallylong_Integer_MSVC_2020_t` creeping in the standard! _Is the backward compatibility of nonstandard code the only reason of the new style of the keywords?_


Tips for a novice PHP developer to drive down long-term maintenance costs

I'm an experienced Java developer who is just starting up a project for an NGO. I will be working on the project for at least 6 months, following which the NGO will have to pay or find a volunteer to maintain the project. Seeing as they already have people working on their website in PHP, I figured PHP was the obvious choice to make sure the skills are still available (it is webby) - eliminated Java because Java devs are typically expensive. Unfortunately I have next to zero experience with proper PHP development (just a few months spending a small percentage of my time on a Drupal project without any real coding). What are some things I can do to ensure that the code I leave behind is maintainable by a relatively low-skilled PHP developer (eg a teenager wanting to make some holiday cash)? Do I go with a CMS? Are Drupal developers cheap? Any other CMS / Framework I should look at? Background: the project is a website that people will search for educational information, with some simple user-management to only allow some users to create content, restrictions to specific content-types etc. The CMS vs write myself question is not the only thing I'm interested in hearing. I'm also interested in any tips about code style, anything you think my Java experience would push me towards that is going to make it difficult for the hypothetical volunteer etc. There's probably things about this scenario that I haven't thought through - so anything related to keeping maintenance costs low would be appreciated.


Reading a specific type of input from file

I have a software that reads from a file. Each object in the software takes 7 inputs viz.      `string string string float string float int`      I have an input file. It contains a number of input values. If input for one object is like: `hss cscf "serving cscf" 32.5 ims 112.134 124`      (Note: when an object's variable needs multi word string, I used "....", for single word string, it is without quotes) How can I read it using ifstream? (I searched google but didn't find.) I tried to read entire line using getline and but again got stuck when it came to find out whether its a single word or multi word input! I thought to read a line and then search char by char. If its '"', I know its a multi word. But I stuck when it comes to an integer or float. For `char`, you can use      `if(line[i]>='a'&&line[i]<='z')`      but how to go ahead when integer or float is the next value? Please give some suggestions for this.


What programming language generates fewest hard-to-find bugs?

What language, in your opinion, allows the average programmer to output features with the least amount of hard-to-find bugs? This is of course, a very broad question, and I'm interested in very broad and general answers and wisdoms. Personally I find that I spend very little time looking for strange bugs in Java and C# programs, while C++ code has its distinct set of recurring bugs, and Python/similar has its own set of common and silly bugs that would be detected by the compiler in other languages. Also I find it hard to consider functional languages in this regard, because I've never seen a big and complex program written in entirely functional code. Your input please. Edit: _Completely arbitrary clarification of hard-to-find bug: Takes more than 15 minutes to reproduce, or more than 1 hour to find cause of and fix._ Forgive me if this is a duplicate, but I didn't find anything on this specific topic.


Explain Cloud computing to Grandmother

Technically I understand what is cloud computing, but I'm having difficulties when trying to explain it to a layman. I am wondering if there are any good examples which could easily explain it.


Are there any Phone Interview equivalents to FizzBuzz?

I think FizzBuzz is a fine question to ask in an in-person interview with a whiteboard or pen and paper handy to determine whether or not a particular candidate is of bare-minimum competence. However, it does not work as well on phone interviews because any typing you hear could just as easily be the candidate's Googling for the answer (not to mention the fact that reading code over the phone is less than savory). **Are there any _phone-interview_ questions that are equivalent to FizzBuzz in the sense that an incompetent programmer will not be able to answer it correctly and a programmer of at least minimal competence will?** Given a choice, in my particular case I am curious about .NET-centric solutions, but since I was not able to find a duplicate to this question based on a cursory search, I would not mind at all if this question became the canonical source for platform-agnostic phone fizzbuzz questions.


Good coding problem/s to use in an interview

I've read a lot of different articles on how to locate good programmers, including the Joel Spolsky and Steve Yegge stuff. Overall I feel we have a pretty good interview process. We ask good questions and we have a coding test problem that we give to candidates to help screen out people that can't actually code; this problem takes a little while and is a "take home" where the candidate is given a few days to return a solution. Overall this process has worked fairly well with us, but we have still landed an occasional dud on the programming front. In at least one case I now suspect that the solution provided was not the candidate's own, but there would be no way to prove this out; nor would it matter as such. We are in an environment where once someone is hired it is incredibly difficult to let them go, so this makes it all the more critical we end up with a good candidate. So I would like to add a **coding exercise** into the actual interview and have the candidate work through a solution in a **pairing style environment** with an existing team member. I'm looking for something that is not terribly complex; something any **competent programmer could solve in about an hour** , but also something a little more difficult that the fizz-buzz problem. * * * I've looked at the following questions as well as other similar questions, but most are slightly different in that they are not asking for specific problems that could fit within the time constraints and are well suited to pairing, or I haven't really seen good answers provided. Code During Interview Favorite Interview Question Passionate Programmer? Fizz Buzz, really? And many many others...


How to protect yourself from being sued by patents?

I've had a few software ideas before that could probably be patented.(decided not to pursue any of them, however). Basically, I don't want these ideas patented though. I don't care if someone else implements them, I just don't want to get sued later by some patent troll who patented the idea I had and implemented 5 years ago. Would posting your idea to public websites, and using the poor man's patent technique ensure that even if someone else patents your idea, you have protection from being sued, and possibly the ability to invalidate their patent?(assuming the reform bill doesn't pass)


Component design: getting cohesion right

I currently have a set of components named DataValues, ValueParsers, ValueFormatters and ValueValidators. The first one defines an abstract base class DataValue and contains a whole load of implementations. The 3 other components each define in interface similar to their name (minus the "s"), and also contain a bunch of implementations of those. These 3 depend on DataValues. There are no further dependencies. In other words, each component currently contains a whole inheritance hierarchy. I recently re-watched EP16 of Robert C. Martin's Clean Coders, where he points out this is one of the most common mistakes made in package design. This made me realize that this exact thing is going on for the here described packages. The question then is how to best improve upon the current component design. Luckily none of those components have seen their first release yet, so things can still be moved around, and boundaries can still be redefined. Releases for these are on the horizon though, so I better get it right now. What I'm thinking of doing now is to create a new component to hold the mentioned abstract class and interfaces for all these components. It would also contain the Exceptions of these components and perhaps some trivial implementations of the interfaces. This new component would then be needed by all the current ones, and by all the ones needing the current ones. Then again, in this later category, there will be a number components that can just depend on the new and get rid of their current dependency on the much more concrete and unstable ones containing all the interface implementations. This is great for the stable dependencies principle, and equally nice for the reuse release equivalence principle. It's however doing rather bad when it comes to the common closure and common reuse principles. Concretely this means that components that need the ValueParsers interface but don't care about the ValueValidators one will still depend on it as it is in the same package. They can thus be affected by it for no good reason. Then again, considering how abstract/stable this new component ends up being, I don't really see this causing much problems. I'm looking for ideas on how to better draw the component boundaries and concerns or suggestions about the alternative I described.


How to deal with people who don't want to share knowledge?

> **Possible Duplicate:**   >  How do you deal with an information hoarder? Often, in IT teams knowledge equals power. This is fine as long as (IT-)knowledge is equally accessible by all members of the team and company specific know-how is well documented. Sometimes personnel in an IT department build up a tremendous amount of know-how _without_ documenting it. By doing so they think that they ensure their position. Often these people like it when people specifically have to ask them how to do a job. How do you get these programmers, database administrators or other IT staff to **_DOCUMENT_** their work and make it accessible to the company they work for? EDIT: It's a relief that so many of you _know_ this type of person. That it is not me bumping into them everywhere I do projects. On the other hand it makes me sad, such talented people but in many ways behaving as a child. I have seen the behavior in men and women btw. It is hard to pick one answer as the best and accept. Will do after more re-reads.


Architectural Patterns for a Game

So I've got a solution that contains a few big projects, which I'm trying to break down into smaller projects with more isolated responsibilities. This is a game I'm tinkering with -- I'm mainly a LOB developer and I think the principles are universal, so I'm hoping to learn something here. The dependencies in some of the objects are a bit too tightly intertwined, and I'm hoping for some help on how to untangle them. Or maybe some sort of pattern or abstraction that might make them more manageable. **Ares.Core.World** has classes in it like Creatures, Items, etc. All of them inherit from Entity, which is aware of what cell on the map it exist at. It accomplishes this by holding a reference to a Ares.Core.UI.MapControls.MapCell... And you can see that the wires are already getting crossed. **Ares.Core.UI.MapControls** contains Map and MapCell, each of which contain Lists of creatures and items that they contain. MapCell also inherits from Ares.Core.World.Entity since that solved a few early problems very elegantly -- for instance, all Entities have inventory. I would like to find a way to split UI and World out into seperate projects ( **Ares.World** and **Ares.UI** ) since UI and the overarching world should probably be seperate concerns. But as you can see, the way it is now the two projects would need to reference each other, and circular references are not allowed. I'm wondering if there are any architectural patterns out there that might help in this situation. Thanks!