title: Machine Learning with sample data set

text: I have a question regarding Machine Learning in general. Consider the following scenario: Given a piece of text, we want a program to know whether the text is 'abusive' or not. To do this we can give the program 1000 text samples and manually mark which ones are positive and which ones are negative. The program studies these and records which words/patterns are common in abusive texts. We then give it another 1000 un-marked texts, and it manages to identify 95% of these correctly using the patterns it learnt from the original 1000. That's all good, but what about after that once the software 'goes live'? That is, we leave it to pull another 1000 texts every day and it's left to determine whether they are abusive or not on it's own. One might think it would be a good idea to continue to recognise words/patterns in an attempt to 'learn' more and more each day? But the problem here is we don't know for sure whether the program is identifying each text correctly. So if it marks a clean text as abusive, it will falsely record words/patterns as abusive. This will then cause the program's intelligence to become more and more incorrect and off-track. What is the general approach to the above problem?


title: Should interface names begin with an "I" prefix?

text: I have been reading "Clean Code" by Robert Martin to hopefully, become a better programmer. While none of it so far has been really ground breaking it has made me think differently about the way I design applications and write code. There is one part of the book that I not only don't agree with, but doesn't make sense to me, specifically in regards to interface naming conventions. Here's the text, taken directly from the book. I have bolded the aspect of this I find confusing and would like clarification on. > I prefer to leave interfaces unadorned. The preceding I, so common in > today’s legacy wads, is a distraction at best and too much information at > worst. **I don’t want my users knowing that I’m handing them an interface**. Perhaps it is because I'm only a student, or maybe because I have never done any professional or team based programming but _I would want the user to know it is an interface._ There's a big difference between implementing an interface and extending a class. So, my question boils down to, **"Why should we hide the fact that some part of the code is expecting an interface?"** **Edit** In response to an answer: > If your type is an interface or a class is your business, not the business > of someone using your code. So you shouldn't leak details of your code in > this thrid party code. Why should I not "leak" the details of whether a given type is an interface or a class to third-party code? Isn't it important to the third-party developer using my code to know whether they will be implementing an interface or extending a class? Are the differences simply not as important as I'm making them out to be in my mind?


title: How to not mix HTML with PHP?

text: I made an application in EXTJS, but my technical architect and project manager say we don't want big file, so removed the EXTJS and made in object oriented PHP and JavaScript code, mixing HTML with PHP. But I don't want to mix HTML and PHP because of bad coding structure and bad coding practice. What should i do?


Should ActiveRecord-based domain models have visible properties? Why or why not? My experience and studies have always lead me to believe that object properties should always be protected, and that data should only be manipulated/accessed through methods. This ensures that if the internals of the class need to be refactored, other objects that rely on that object do not then also need to be refactored. I often see domain models with publicly visible properties however, and the models can be passed to say view objects which directly access those properties while building the view. I have always thought that this is perhaps the one exception to the above mentioned rule, because otherwise you would basically have to create getters and setters for objects like the view to use, or some other equally troubling sounding solution. Perhaps I am wrong on this? I would like to get some feedback on the subject.


title: Is there a good reason to avoid node.js for non-realtime web apps?

text: I've seen a lot of talk about how awesome Node.js is for realtime web apps -- things that need sockets, Comet, AJAX-heavy communications, and so forth. I know that its event-driven, asynchronous, thread-driven model is also good for concurrency with low overhead. I've also seen Node.js tutorials for more simple, 'traditional', non-realtime apps (e.g., the standard blog example, which seems to be the standard 'Hello World' for people learning app development). And I also know that node-static allows you to serve static assets. My question is: is there any good reason to _avoid_ Node.js for traditional web apps, like classifieds, forums, the aforementioned blog example, or the sort of CRUD apps you build for internal business applications? Just because it excels at all the funky realtime stuff, does that contraindicate it for more staid uses? The only thing I can think of, off the bat, is the lack of mature libraries (although that's changing). (The reason I'm asking is that I'm considering ditching PHP for Node.js, mostly to get over the impedance mismatch of switching between languages, but also so I can reuse validation code and whatnot. My superego admonishes me to choose the best tool for the job; however, I don't have a lot of time to learn fifteen languages and all their userland libraries just to have a comprehensive arsenal. It's also reassuring that Node.js might give me an easier optimisation path than PHP/Apache in the future when I have to start thinking about heavy traffic.) **[EDIT]** Thanks for the answers so far, folks; I just want to see if anyone else will weigh in before I choose an answer. The answer from @Raynos kinda confirms what I'm thinking, and the links from the commenters provided good food for thought, but I want to see if anyone else has any Node-specific answers, like 'DON'T USE NODE FOR PROBLEM X'. (Besides high-CPU tasks; I know that already :-)


title: How to deal with designers?

text: > **Possible Duplicate:**   >  How do you handle a graphic designer who thinks he's a web designer? As a mobile/web developer in my company, I deal a lot with designers (i.e. Adobe suite designers). The problem is that these designers always want things from their point of view, by which I mean, they don't understand UX rules and other things such as how users interact with the software. And this is where problems start... Any suggestion on how to deal with them?


title: Software Process Management

text: We want to formalize our development process. Aim is to provide a clear view of software in each phase. For example, to translate requirements to task, to specify the pre and post-conditions of task etc. So that each role (analyst, developer, tester) can perform better and has a checklist to finish his job properly Does your company follow any software process e.g. Agile, OpenUP, RUP etc. If yes what tools do you use to enforce it or to facilitate it?


title: When does a "scripter" become a "programmer"?

text: Is there a difference between 'scripters' and 'programmers'? What is the dividing line between scripters and programmers? Perhaps all scripters be considered to be a programmer. If not all scripters can fall into the same camp, what about those people who use external objects such as COM objects, Win32's, etc. via an interop library? As far as script languages I'm thinking of are (but not limited to) perl, bash, javascript, powershell, and batch files.


title: .Net - web controls and win form controls

text: The next version of the application will be a .NET based application (both desktop and web). The **requirement** is that both applications have to look and work exactly the same way. I was thinking that maybe there was a way to create a web control or something and use it in both applications. Is this possible? For example can I create a user control for the web and use it for the desktop (without using a web browser control)? If the above isn't possible, what are my alternatives? Please let me know.


title: How frequent should the Token Updation in CSRF security be?

text: To start with the background, this post is what Jeff Atwood says about CSRF tokens. In this very page, he goes on to say: > An even stronger, albeit more complex, prevention method is to leverage > server state -- to generate (and track, with timeout) a unique random key > for every single HTML FORM you send down to the client. We use a variant of > this method on Stack Overflow with great success. But in this post itself, Jeff never remarks about when and how the tokens should be updated. I was using a similar technique in a web-app I was working on. It works like this:   1. Whenever the user will `POST` data to my server, a csrf token is sent along.   2. This CSRF token is stored in a cryptographically strong cookie in user's session.   3. If the token is valid, the user's request is processed and vice-versa.   4. If the request is valid, discard the old token on server side and create a new token. The response from server contains a new csrf token to be used in the next request. The old token on all the forms on a page is updated with the new one so that the next request is processed properly. Is it wise to update the tokens after ever `POST` request or should the updation be done only whenever the user makes a `GET` request and keep the same token till the next GET request is made?


title: How does a government development shop transition to developing open source solutions?

text: Our shop has identified several reasons why releasing our software solutions to the open source community would be a good idea. However, there are several reasons from a business stand point why converting our shop to open source would be questioned. I need help from anyone out there who has gone through this transition, or is in the process. Specifically a government entity. About our shop: \- We develop and support web and client applications for the local law enforcement community. \- We are NOT a private company, rather a public sector entity Some questions that tend to come about when we have this discussion are:   1. We're a government agency, so isn't our code already public?   2. How do we protect ourselves from being 'hacked' if someone looks into our code? (There are obvious answers to this question like making sure you don't hard code passwords, etc. However, the discussion needs to consider an audience of executives who are very security conscience.)


title: Is it possible to deploy Perl or Python scripts in the same way as PHP scripts?

text: PHP's deployment model is uber simple: upload and run. This is especially ideal for web applications that are intended to be installed on shared hosting by end users (think: Wordpress). Compare this with the installation of a popular Perl app. I want to stop writing things in PHP, but want to keep the same deployment model. Is it possible to achieve this with Python or Perl in such a way that it'll work with most shared web hosts? In other words, how can I run Python or Perl scripts outside of the cgi-bin directory on most shared hosts, like I can with PHP scripts?


title: Why do schools (or most schools) teach Java as the intro language?

text: > **Possible Duplicate:**   >  Why do we study Java at university? This is a question I've wondered a lot as a young developer that just graduated from college. Why do schools teach Java in-depth vs something like C? A lot of my co-workers complain that there are no good C programmers anymore because schools no longer teach C in any real form. For example, my first 6-8 undergrad CS courses were all in Java. Then I had exactly 2 courses in upper division that used C and C++, and the rest were in Java. That was it. A lot of students had to retake the C/C++ classes because nobody had introduced us to C/C++ or any concepts in C/C++. We were just expected to somehow program instantly in C/C++. Now you could say that once you learn a language, everything other language is more or less the same but a lot of my classmates had problems with pointers and memory allocation. I think I honestly spent half the quarter understanding pointers and memory allocation before I sort of understood it and even now I am not confident enough to say I truly understand it. So why do schools do this? I've heard many developers say that going from C/C++ as a first language to Java is easy, but the reverse is much more difficult (This is also my sentiment). So why not do C/C++ first?


title: Writing commit messages as a solo developer?

text: On my projects where the repository is shared between me and other programmers, I always write commit messages even if I'm the primary developer. But on those projects where I'm the solo developer working on a project, and the repository is hosted on my personal laptop, and is not even hosted by the client, hence no one except myself would see the commits, should I still write commit messages? So far I have been writing them, but I've found that I've never gone back and viewed my commit messages. I take time off development to write down the messages, but then they're never seen again even by me. Are there any good reasons for writing commit messages as a solo developer, or should you just skip them in favor of staying focused on development?


title: How to deal with users who think their computer could think?

text: Along my career, I had to deal with users who think their computer could think: > My computer hates me! or > He just do this so he could laugh at me! This is often a joke, but some users are serious. It's easy when I know the causes of the problem, but when it's unexpected behavior it's more complicated. In those cases, I usually turn it as a joke, putting that on the fault of moon phases and tide, but they are likely to prefer their explanations. Do you have any tricks to deal with those users?


title: Creating a blog for software changes

text: I work for a small company where I maintain a number of project all at once. I would like to create a blog and note software changes/update so that I can keep track of things. Plus it will also serve as help tool for other if they need help. I would like to install something locally on my machine or network, either ASP or PHP is fine. **Which software would you recommend? Is it good idea, bad idea? Has anyone done it? I have worked with wordpress and I like it but I am afraid it is not best for code snippets.** Any thoughts I do use source control. I am not an expert on it though. I use three different development environment. 1. Visual Studio 2. Eclipse 3. SQL Server Management Studio


title: Use unnamed object to invoke method or not?

text: If I have a class with only only public method. When I use this class, is it good to use unnamed object to invoke its method? normal:               TaxFileParser tax_parser(tax_file_name);     auto content = tax_parser.get_content();      or unnamed object version:               auto content = TaxFileParser(tax_file_name).get_content();      Because I've told that we should avoid temporary as possible. If `tax_parser` object is used only once, can I call it a temporary and try to eliminate it? Any suggestion will be helpful.


title: Programming *into* a language vs. writing C code in Ruby

text: Code Complete states that you should aways code _into_ a language as opposed to code _in_ it. By that, they mean > Don't limit your programming thinking only to the concepts that are > supported automatically by your language. The best programmers think of what > they want to do, and then they assess how to accomplish their objectives > with the programming tools at their disposal. (chapter 34.4) Doesn't this lead to using one style of programming in every language out there, regardless of the particular strengths and weaknesses of the language at hand? Or, to put the question in a more answerable format: Would you propose that one should try to encode one's problem as neatly as possible with the particulars of one's language, or should you rather search the most elegant solution overall, even if that means that you need to implement possibly awkward constructs that do not exist natively in one's language?


title: Is this bad design for a Shape interface?

text: I'm creating a vector editing program in C++, and I need a Shape interface which other concrete classes will implement. There is a requirement that _no implementation inheritance_ is allowed. The design doc says that if you need polymorphism, **use interfaces**. If you need code reuse, **use composition**. The **Shape** interface is:               class Shape     {       public:             virtual void get_name()=0;        virtual void set_name()=0;        virtual void get_linewidth()=0;        virtual void set_linewidth()=0;             ...        ...about 20 other getters/setters        ...             virtual void draw()=0;        virtual int area()=0;        virtual void rotate(int angle)=0;          }      The Circle class:               class Circle: public Shape     {       string name;       int line_width;       int angle_of_rotation;       int radius;     public:       string get_name(){ return name; }       string set_name(string name){ this->name=name; }       ...       ...about 20 other getters/setters       ...            int area()       {         return PI*pow(this->radius,2);       }          }      I have no problem with this, except common properties have to be **repeated for each type of shape**! This is solved using inheritance, but I am **not allowed to use that**. So, I create a **ShapeProperties** class               class ShapeProperties     {       string name;       int line_width;       int angle_of_rotation;          public:            string get_name(){ return name; }       string set_name(string name){ this->name=name; }            ...       ...about 20 other getters/setters       ...          }      and a properties() method for the interface:               virtual ShapeProperties* properties()=0;      A user would then do:               Shape *shape = new Circle();     shape->properties()->set_name("my shape");     shape->properties()->set_line_width(4);     int area = shape->area();      **My question:** Is this good design? Is this bad design? Are there any obvious problems? How could it be made better?


title: How to simplify my complex stateful classes and their testing?

text: I am in a distributed system project written in java where we have some classes which corresponds to very complex real-world-business objects. These objects have a lot of methods corresponding to actions that the user (or some other agent) may apply to that objects. As a result, these classes became very complex. The system general architecture approach has lead to a lot of behaviors concentrated on a few classes and a lot of possible interaction scenarios. As an example and to keep things easy and clear, let's say that Robot and Car were classes in my project. So, in the Robot class I would have a lot of methods in the following pattern:   * sleep(); isSleepAvaliable();   * awake(); isAwakeAvaliable();   * walk(Direction); isWalkAvaliable();   * shoot(Direction); isShootAvaliable();   * turnOnAlert(); isTurnOnAlertAvailable();   * turnOffAlert(); isTurnOffAlertAvailable();    * recharge(); isRechargeAvailable();   * powerOff(); isPowerOffAvailable();   * stepInCar(Car); isStepInCarAvailable();   * stepOutCar(Car); isStepOutCarAvailable();   * selfDestruct(); isSelfDestructAvailable();   * die(); isDieAvailable();   * isAlive(); isAwake(); isAlertOn(); getBatteryLevel(); getCurrentRidingCar(); getAmmo();   * ... In the Car class, it would be similar:   * turnOn(); isTurnOnAvaliable();   * turnOff(); isTurnOffAvaliable();   * walk(Direction); isWalkAvaliable();   * refuel(); isRefuelAvailable();   * selfDestruct(); isSelfDestructAvailable();   * crash(); isCrashAvailable();   * isOperational(); isOn(); getFuelLevel(); getCurrentPassenger();   * ... Each of these (Robot and Car) is implemented as a state machine, where some actions are possible in some states and some aren't. The actions changes the object's state. The actions methods throws `IllegalStateException` when called in an invalid state and the `isXXXAvailable()` methods tell if the action is possible at the time. Although some are easily deducible from the state (e.g, in the sleeping state, awake is available), some aren't (to shoot, it must be awake, alive, having ammo and not riding a car). Further, the interactions between the objects are complex too. E.g, the Car can only hold one Robot passenger, so if another one try to enter, an exception should be thrown; If the car crashes, the passenger should die; If the robot is dead inside a vehicle, he can't step out, even if the Car itself is ok; If the Robot is inside a Car, he can't enter another one before stepping out; etc. The result of this, is as I already said, these classes became really complex. To make things worse, there is hundreds possible scenarios when the Robot and the Car interacts. Further, much of that logic does needs to access remote data in other systems. The result is that unit-testing it became very hard and we have a lot of testing problems, one causing the another in a vicious circle:   * The testcases setups are very complex, because they need to create a significantly complex world to exercize.   * The number of tests is huge.   * The test suite takes some hours to run.   * Our test coverage is very low.   * The testing code tends to be written weeks or months later than the code that they test, or never at all.   * A lot of tests are broken too, mainly because the requirements of the tested code changed.   * Some scenarios are so complex, that they fail on timeout during the setup (we configured a timeout in each test, in the worst cases 2 minutes long and even this time long they timeouts, we ensured that it is not an infinite loop).   * Bugs regularly slips into production environment. That Robot and Car scenario is a gross over-simplification of what we have in reality. Clearly, this situation is not manageable. So, I am asking help and suggestions to: 1, Reduce the classes complexity; 2. Simplify the interactions scenarios between my objects; 3. Reduce the test time and the amout of code to be tested. EDIT:   I think I was not clear about the state machines. the Robot is itself a state machine, with states "sleeping", "awake", "recharging", "dead", etc. The Car is another state machine. EDIT 2: In the case that you are curious about what my system actually is, the classes that interact are things like Server, IPAddress, Disk, Backup, User, SoftwareLicense, etc. The Robot and Car scenario is just a case that I found that would be simple enough to explain my problem.


title: How often is Inheritance used?

text: I admit that I am a junior developer, and so far I've only built simple web applications in ASP.NET MVC. But I've never had to use the inheritance aspect of Object Oriented Programming in my own classes! It is true that in using ASP.NET MVC I inadvertently use inheritance (any controller I create will inherit from the base controller class), but I am referring here to the conscious use of inheritance in my design of a particular web system. Is it because I am a bad programmer? Or could it be that inheritance only comes into play in certain scenarios? Don't get me wrong, I understand what inheritance is and how to code using inheritance if I had to. I just can't seem to find a scenario to use it at. Basically, I am wondering how often it is used in OO programming in general.


title: Can you be a programmer and Business manager at the same time?

text: I think I'm struggled in some situation! We are a new start-up with 5 employees (2 Programmers). I'm the Technical Manager and that was so fine! Now I can see the fingers point to me to take the control of everything, as I've the big vision of what our organization do and play the role of CEO or General Manager! I want to, but I've no idea if it would be risky to our organization to make such a decision? How would managerial interrupts affect the technical productivity? Any tips or previous experience about such situation would help :) Thanks in advance!


title: Object-Oriented Programming: Why "Oriented"?

text: I am most of the way through my games programming degree. This is not a computer science degree, so a lot of the theory is eschewed in favour of practical portfolio building and what I see as JIT learning, which is apparently more important in the games industry. The first subject was "Introduction to Object-Oriented Programming". That phrase didn't bother me until I learned about the different programming paradigms (I'm getting this list from https://en.wikipedia.org/wiki/Comparison_of_programming_paradigms):   * Imperative   * Functional   * Procedural   * Structured   * Event-Driven   * Object-Oriented   * Declarative   * Automata-Based I get that this is not an exhaustive list, and that not all of these concepts are equal, and most of them aren't even exclusive, but I don't understand why most of them get just one word - imperative; functional; declarative - but when we talk about programming with objects, we have to clarify that we are _oriented_ around those objects. Can't we just _use_ objects? Can't we just _have_ objects? Why must they _orient_ us, as our guiding star? Looking here (https://en.wikipedia.org/wiki/Object-oriented_programming), nowhere is the use of the term "oriented" addressed as its own term. Only "object" is explained. Also, I can see for practical reasons why Event-Driven is used, because Event Programming is already a thing that you do when you're running a conference, and Automata Programming makes it sound like you're setting up a robotic production line, so it helps to have additional clarifying words there. **What makes Object Programming, as a phrase, not enough to describe what we do when we use objects in our programming?** Obviously from my tone I'm not too fond of the word "oriented". It reminds me of my time as a court reporter, listening to lawyer after lawyer use the phrase "in relation to" as a kind of verbal tick. It didn't mean anything; it was just a term that they used to fill the air while they tried to think of what to say next. However, I'm not trying to advocate a change of language, I'm just asking why it is the way it is. If someone knows why it came to be known that way for purely historical, vestigial reasons, then that's the answer. It will be ammunition if I ever decide to waste my time advocating for a change of language. On the other hand, if there is actually a useful reason for why a language or piece of code must _point_ towards objects, to the exclusion of all other directions, as opposed to merely having them in its toolbelt, as _tools_ , I would really be interested to learn about it. I like learning useful things.


title: Can REST API be used as business layer?

text: I am using PHP Codeigniter **MVC** design pattern and I had this project with some sort of specific business processes In my application I will be dealing with 2 existing REST APIs:   1. Google    2. Trello I came up with idea to create **REST API** to act as **Business Logic Layer** (BBL) that in turns access my models directly to fetch needed data to formulate business rules and controller with communicate with BLL with REST client, ![enter image description here](http://i.stack.imgur.com/p5rMQ.png) Is that bad approach for performance ? Is it better to create **2 layers** of Models one as Data Access Layer **(DAL)** and one as Business Logic Layer **(BLL)**


title: BLL structure and organization

text: let's say you have a class diagram http://i.stack.imgur.com/gpb55.png and you would like to start a class library project in visual studio to act as BLL to convert this diagram into actual code files. how would you structure your BLL project (in the solution explorer), how would you organize classes files and thier hierarchy?


title: State pattern long state class names

text: I am using state pattern on 28 states in my application. The states are for membership cards that has 7 major states, there are 4 boolean attributes for the membership card that actually affects the its behavior so I have decided to embed them with states, that's how it multiplied to 28 states. The problem now is with states class naming, it is getting crazing, I am ending up with class state named like this `Membership-UnderCreation-Printed- Linked-Premium-Frozen` \----- I have hyphened different attributes to make it clear. Is it ok for state class names to be like this?


title: Preventing Web Users From Using Their Location Bar Within An App

text: My boss asked me to alter our Java Webapp such that users cannot go to places in our Webapp by typing URLs into their browser location bar. I told her that I can not disable their location bars. I told her the way this is usually done is to launch a WebApp in a new customized browser window sans a location bar. That was not acceptable to her. I already have a Java Filter class set up to enforce various rules. So, I was thinking of this approach   1. Implement a system wide "writeFlagCookie" javascript function to write a cookie anytime a user initiates a GET by clicking on a link or a button.   2. Everywhere the WebApp does a redirect or a forward, put a flag variable, say "wasRedirected" into the HTTP session.   3. In my Filter, intercept each request and check for the request type.   4. If it is a POST, I know a human didn't type the URL into their browser, so I automatically let it through.   5. If it is a GET, look for a javascript generated cookie, or the flag stored in the session to indicate a redirect or a forward. If I find neither send the user back to the page they just tried to leave from. Though it will be a lot of work, it sounds too simple to be adequate. Is there anyway this approach can bite me in the ass? My boss wants two problems solved   1. Users going to screens out of sequence and getting error messages. This includes multi-screen forms ( which we have to keep ) and users using a back button.    2. Preventing the user from leaving particular pages and going to other parts of the application until they fill out what we want them to fill out on those screens. I have ideas how to solve #1 & #2, also laborious, but my boss likes the idea of disabling typing URLs for navigation for a catch-all solution. Maybe once she sees how much work is involved in disabling typed navigation I can market her on just solving those problems. Thanks Steve


title: how to write a stored procedure to insert data in to a sql server database in a datagridview in a form?

text: I need to insert data through a form using a `datagridview` connected to a SQL Server 2008 R2 database. is it ok, if I write a single insert stored procedure query in a while loop in the `form.cs`


title: How difficult did you find the Java Certification Exam

text: I'm just starting out as a Java programmer and have very minimal experience. I would like to improve my knowledge and study for the Java certification. I realize everyone will have a different answer but for those who have taken the certification and passed it, I'd really appreciate if you could tell me your experiences. Just a couple of lines to let me know if you found it hard, very hard. Also how much time did you spend studying. Sorry that this is not a good question. My native language is not English so it is hard for me to say what I want to ask.


title: Having 2 Initialize Paragraphs in 1 COBOL program

text: I am designing a COBOL program that does 2 things.   1 reads specific rows from a table, and inserts a new row based on the original.   2 reads different rows from the same table, and updates those rows. Is it bad standards to have 2 initialization procedures? I need to declare 2 SQL cursors, one for each task. So I was thinking:   `1 initialize cursor, 2 process, 3 initialize cursor, 4 process.` But that seems like bad logic. something is telling me it should be more like:   `1 initialize cursor, 2 process` But I'm having trouble thinking it out because to me, they are 2 separate tasks. I tried to think of a way that my SQL query could do the work, and then I could just do some validation. But I'm not sure the query would be any more efficient than having a second read of the table. Here's my structure ideas   I've added a 3rd chart that I believe follows the answer given to me on this question. Does the 3rd chart seem to me the most logical?


title: Should I keep all my class definitions in the same class library?

text: I am starting to work with class libraries in my C# class. We were told to write code that can be used more than one time. Should I keep all my class definitions in one class library for the length of the term, or separate them by project?


title: Is Objective C a reasonable way to learn C?

text: I want to learn C but I tend to learn best when I have a project to work on. I've never done iPhone development, so I'm hoping to kill two birds with one stone. Will learning objective c also teach me to program c reasonably well, or are they too dissimilar? EDIT: I'm mostly wondering if objective-c/iphone-development would teach me all the little gotcha's that are inherent to c. I come from a .Net background so I haven't done much in terms of memory management or working with pointers.


title: Finding maximum number of congruent numbers

text: Let's say we have a multiset (set with possible duplicates) of integers. We would like to find the size of the largest subset of the multiset such that all numbers in the subset are congruent to each other modulo some m > 1. For example:   1 4 7 7 8 10 for m = 2 the subsets are: (1, 7, 7) and (4, 8, 10), both having size 3.   for m = 3 the subsets are: (1, 4, 7, 7, 10) and (8), the larger set of size 5.   for m = 4 the subsets are: (1), (4, 8), (7, 7), (10), the largest set of size 2.   At this moment it is evident that the best answer is 5 for m = 3. Given m we can find the size of the largest subset in linear time. Because the answer is always equal or larger than half of the size of the set, it is enough to check for values of m upto median of the set. Also I noticed it is necessary to check for only prime values of m. However if values in the set are large the algorithm is still rather slow. Does anyone have any ideas how to improve it?


title: DDD/SOA in (.NET) MVC and Message pattern(s) / Request Response

text: We're currently considering whether it makes sense (or if the benefits are worth the added code) to introduce a Message based pattern (such as Request Response) into a Domain Driven Design / Service Oriented Architecture under an MVC app (with DI and potentially used by MVC, WCF, Windows Services, etc.). Basically (in MVC) the controller uses an injected service which in turn uses an injected repository to save/update/delete objects. There are Application Services, and Domain Services and the application service might use multiple domain services to e.g. save something and then send an email about the item being saved. Considering the `example use case` where something is saved and then an email is sent, it could be useful to present any potential errors to the user such as "Save succeeded, but the email wasn't able to be sent. Please try again in 5 minutes or contact support etc." vs just a generic error such as "Save or email didn't succeed". The message based pattern with Request and Response objects seems fine (in theory), or at least the response objects with e.g. a couple inherited fields could be useful.               public abstract class ResponseBase     {         public bool Success { get; set; }         public string Message { get; set; }     }      Then there could be an object to extend it with the ViewModel result as a property and finally the controller could decide whether to show e.g. an error message, or update the view etc. This seems nice, but in the `simple cases` where you are simply saving an item and it's clear the save succeeded or failed, it can also seem to be overkill. Creating and passing extra objects where maybe you just need an ID and a Boolean seems to make this pattern redundant. The thing is that this object needs to transfer from the controller, through the services, down to the repository, and back. The request part could be possible to ignore and only worry about returning a meaningful result too. It's hard to estimate whether it could be 50-50 or 40-60 where this type of system could be useful, but there are many cases that could use it, as well as many that aren't very useful. Is there better approaches to this issue, or have you found this pattern useful for the scenario portrayed? Is it worth the extra coding for the simple cases (in your case(s))?


title: Untyped lambda calculus: Why is call-by-value strict?

text: I'm currently reading Benjamin C. Pierce's “Types and Programming Languages”. Before really getting into type theory it explains lambda calculus and evaluation strategies. I am a bit confused by the explanation of _call by name_ vs _call by value_ in this context. The two strategies are explained in the following manner: ### _call by name_ Like _normal order_ in that it chooses the leftmost, outermost redex first, but more restrictive by not allowing reductions inside abstractions. An example:                 id (id (λz. id z))     → id (λz. id z)     → λz. id z      ### _call by value_ Only the outermost redexes are reduced and a redex is reduced only when its right-hand side has already been reduced to a value—a term that is finished computing and cannot be reduced any further. An example:                 id (id (λz. id z))     → id (λz. id z)     → λz. id z          (identical to the call by name evaluation)      Ok, so far so good. But this is followed by the following paragraph: > The call-by-value strategy is _strict_ , in the sense that the arguments to > functions are always evaluated, whether or not they are used by the body of > the function. In contrast, _non-strict_ (or _lazy_ ) strategies such as > call-by-name and call-by-need evaluate only the arguments that are actually > used. I know what call-by-value and call-by-name means practically, from having used (among others) C and Haskell, but I cannot see why the evaluation strategy explained above leads to this in the lambda calculus. Is this an additional rule that always accompany call-by-value, or does if follow from the reduction strategy outlined above? Especially since the reduction steps in the examples are identical, I fail to see the difference between the two strategies and would love if someone could help me gain some intuition.


title: How can I create a web form that displays and accepts Tamil language?

text: I am developing a PHP Application that needs to display and accept content written in tamil. For example "login" should be written in tamil on the form. How can I achieve this ?


title: Naming Convention for Dedicated Thread Locking objects

text: A relatively minor question, but I haven't been able to find official documentation or even blog opinion/discussions on it. Simply put: when I have a private object whose sole purpose is to serve for private `lock`, what do I name that object?               class MyClass     {         private object LockingObject = new object();              void DoSomething()         {             lock(LockingObject)             {                 //do something             }         }     }      What should we name `LockingObject` here? Also consider not just the name of the variable but how it looks in-code when locking. I've seen various examples, but seemingly no solid go-to advice:   1. Plenty of usages of `SyncRoot` (and variations such as `_syncRoot`).     * **Code Sample:** `lock(SyncRoot)`, `lock(_syncRoot)`     * This appears to be influenced by VB's equivalent `SyncLock` statement, the `SyncRoot` property that exists on some of the ICollection classes and part of some kind of SyncRoot design pattern (which arguably is a bad idea)     * Being in a C# context, not sure if I'd want to have a VBish naming. Even worse, in VB naming the variable the same as the keyword. Not sure if this would be a source of confusion or not.   2. `thisLock` and `lockThis` from the MSDN articles: C# lock Statement, VB SyncLock Statement     * **Code Sample:** `lock(thisLock)`, `lock(lockThis)`     * Not sure if these were named minimally purely for the example or not     * Kind of weird if we're using this within a `static` class/method.     * EDIT: The Wikipedia article on locks also uses this naming for its example   3. Several usages of `PadLock` (of varying casing)     * **Code Sample:** `lock(PadLock)`, `lock(padlock)`     * Not bad, but my only beef is it unsurprisingly invokes the image of a _physical_ "padlock" which I tend to not associate with the _abstract threading concept_.   4. Naming the lock based on what it's intending to lock     * **Code Sample:** `lock(messagesLock)`, `lock(DictionaryLock)`, `lock(commandQueueLock)`     * In the VB SyncRoot MSDN page example, it has a `simpleMessageList` example with a private `messagesLock` object     * I don't think it's a good idea to name the lock against the type you're locking around ("DictionaryLock") as that's an implementation detail that may change. I prefer naming around the concept/object you're locking ("messagesLock" or "commandQueueLock")     * Interestingly, I _very rarely_ see this naming convention for locking objects in code samples online or on StackOverflow.   5. (EDIT) The C# spec under section "8.12 The Lock Statement" has an example of this pattern and names it `synchronizationObject`     * **Code Sample:** `lock(SynchronizationObject)`, `lock(synchronizationObject)` **Question:** What's your opinion _generally_ about naming _private_ locking objects? Recently, I've started naming them `ThreadLock` (so kinda like option 3), but I'm finding myself questioning that name. I'm frequently using this locking pattern (in the code sample provided above) throughout my applications so I thought it might make sense to get a more professional opinion/discussion about a solid naming convention for them. Thanks!


title: git changing head not reflected on co-dev's branch

text: Basically, we undid history. I know this is bad, and I am already committed to avoiding this at all costs in the future, but what is done is done. Anyway, I issued a git push origin <1_week_old_sha>:master to undo some bad commits. I then deleted a buggered branch called release(which had also received some bad commits) from remote and then branched a new release off master. I pushed this to remote. So basically, remote master & release are clones and just how I want them. The issue is if I clone the repo anew(or work in my current repo) everything looks great....but when my co-devs delete their release branch and create a new one based off the new remote release I created, they still see all the old junk I tried to remove. I feel this has to do with some local .git files mistaking the new branch release for the old release. Any thoughts? Thanks.


title: Useful git commit messages for merged branches

text: _As a follow-up tothis question:_ If I'm working on a team by myself, I can maintain useful commit messages when merging branches by squashing all the commits to a single diff and then merging that diff. That way I can easily see what changes were introduced in the branch, and I have a single summary describing the feature/change/whatever that was accomplished in that branch when browsing the master branch. My question now is, how can I accomplish this when working with a team? In that situation, the branches will be pushed to a remote repository, meaning that I can't squash all the commits in the branch down to a single commit. If the branch is public, can I still have a single useful merge commit in the master branch? (By "useful" I mean that the commit in the master line tells me (1) a useful summary of what was done in the branch and (2) diffs of the same.)


title: Optimization of a hybrid pagination scheme

text: I'm working on a Web Application using node.js in which I'm building a partial copy of the database on the client-side to decrease the load on my server. Right now, I have a function like this (expressed as python-style pseudocode, but implemented in JavaScript):               get(table_name,primary_key):         if primary_key in cache[table_name]:             return cache[table_name][primary_key]         else:             x = get_data_from_server(table_name,primary_key) # socket.io             return cache[table_name][primary_key] = x      While this scheme works perfectly well for caching individual rows, I'd like to extend it to support the creation of paginated tables ordered according to the primary_key, and loading additional data using the above function for only the current and possibly the adjacent pages. Now, I don't want to keep the list of primary keys on the server to be retrieved every time I need to change the page (which, for reasons beyond the scope here, will be very frequent), and keeping it on the client side, subject to real-time create/delete events from the server, doesn't seem that good an idea, even after compression (using ranges, instead of individual values). What is the best way to calculate which items are to be displayed on a random page, minimizing the space requirements & the need for communication with the server?


title: Is Agile the new micromanagement?

text: This question has been cooking in my head for a while so I wanted to ask those who are following agile/scrum practices in their development environments. My company has finally ventured into incorporating agile practices and has started out with a team of 4 developers in an agile group on a trial basis. It has been 4 months with 3 iterations and they continue to do it without going fully agile for the rest of us. This is due to the fact that management's trust to meet business requirements with a quite a bit of ad hoc type request from high above. Recently, I talked to the developers who are part of this initiative; they tell me that it's not fun. They are not allowed to talk to other developers by their Scrum master and are not allowed to take any phone calls in the work area (which maybe fine to an extent). For example, if I want to talk to my friend for kicks who is in the agile team, I am not allowed without the approval of the Scrum master; who is sitting right next to the agile team. The idea of all this or the agile is to provide a complete vacuum for agile developers from any interruptions and to have them put in good 6+ productive hours. Well, guys, I am no agile guru but what I have read Yahoo agile rollout document and similar for other organizations, it gives me a feeling that agile is not cheap. It require resources and budget to instill agile into the teams and correct issue as they arrive to put them back on track. For starters, it requires training for developers and coaching for managers and etc, etc... The current Scrum master was a manager who took a couple days agile training class paid by the management is now leading this agile team. I have also heard in the meeting that agile manifesto doesn't dictate that agile is not set in stones and is customized differently for each company. Well, it all sounds good and reason. In conclusion, I always thought the agile was supposed to bring harmony in the development teams which results in happy developers. However, I am getting a very opposite feeling when talking to the developers in the agile team. They are unhappy that they cannot talk anything but work, sitting quietly all day just working, and they feel it's just another way for management to make them work more. Tell me please, if this is one of the examples of good practices used for the purpose of selfish advantage for more dollars? Or maybe, it's just us the developers like me and this agile team feels that they don't like to work in an environment where they only breathe work because they are at work. Thanks. Edit: It's a company in healthcare domain that has offices across US. It definitely feels like a cowboy style agile which makes me really not wanting to go for agile at all, esp at my current company. All of it has to do with the management being completely cheap. Cutting out expensive coffee for cheaper version, emphasis on savings and being productive while staying as lean as possible. My feeling is that someone in the management behind the door threw out this idea, that agile makes you produce more so we can show our bosses we're producing more with the same headcount. Or, maybe, it will allow us to reduce headcount if that's the case. EDITED: They are having their 5 min daily meeting. But not allowed to chat or talk with someone outside of their team. All focus is on work.


title: Converting our Windows Software to the web

text: We're looking at converting a software package from Windows over to the browser. It's a back office system consisting of Ledgers, Stock Control, Order Processing, etc and it's written in a legacy language (Dataflex). The project consists of 200+ database tables, 100+ reports, 300+ Views, 100+ Dialog boxes and 200 or so Selection Lists. I'm really struggling to get my head around the technologies that I'll need to use to convert this to a more modern web based programming language / framework. Even simple screens (Entering a stock location) seems overly complex. With the current language, I can drag a bunch of Fields to a form (a-la VB), wire in a tiny bit of database code and I've got a screen that'll allow me to find, delete, edit and change records easily. 10 minutes of development, tops. Has anyone got any suggestions on how I can move from my current VB style programming language to one that allows similar functionality on the web? Has anyone got any ideas how I go about working out how many man hours it's going to take to convert this sort of project to a new language on the web? What Web Framework options are available, and how do I decide between going with something like Rails vs going with something like ASP.Net? We've a tonne of code wired to OnClick and OnChange events. (I know this is bad). What strategies can I take with regard to converting this to the web? I'll admit - I'm hopelessly confused by some of the newer syntaxes used by modern languages. Is there any language that allows me access to the database without having to subclass everything through IEnumerable and various weird Typecasting things. Has anyone done anything like what we want to do? What were the pitfalls? Sorry about the vagueness of the question. I'd be more specific but don't know where to start. Delete away if I'm asking the wrong thing or in the wrong place.


title: Class Naming in Stock Trading Application

text: What do you normally call a class that stores open, high, low, close, volumne, and timestamp of a financial instrument(e.g. stock)? For example, in a 5 minute intraday chart, this object would hold OHLC, and volume between 10:00 and 10:05AM. Can anyone working in the field give me an advice?


title: Why are there non-decidable languages? Can anyone explain me my book's solution?

text: Well in my book it is says that "there are non-decidable languages" And the proof is: > Every algorithm is a word. Then there are only countable algorithms. But > there are uncountable languages and therefore more than algorithms Why is it said that every algorithm is a word? A word is a concatenation of symbols, elements of an alphabet, then what's the relation between a word and an algorithm? Can anyone explain me that?


title: Using only UI testing. Is that Ok?

text: I am a sole developer working with an offshore employer. I do realize the importance of unit testing (although haven't practiced before) but currently, the code hasn't ever been tested. The problem with the code is that it isn't what I call "been moduled well", some parts are really messy, extensive use of globals and the code doesn't really show loose coupling. If I am not wrong, the code might require heavy refactoring before being able to be unit tested. Also, it seems the employer, isn't quite interested in testing. He rather suggests to spend this time in building features. So what I suggested to him is UI testing. Because UI testing is something we do every time, testing features, clicking, checking if something is not broke, it made sense to both of us to use it to automate the process of checking features and save us time. Since I have never done UI testing before, I don't know what possible disadvantages might be associated with using just UI testing alone or will it be much beneficial at all?


title: Javascript Architectural Model

text: Are there any obvious flaws to this OO architectural model which I intend to implement using javascript? It is similar to the MVP model but instead the role of the model is broken down into three modules:   * the cache (stores data instead of rerequesting from server)   * the model (manages requests for raw data, retrieving it from the cache if available or the server)   * the modifier (handles requests which require data which makes changes to the data on the server) For a diagram showing how data flows through this model: ![enter image description here](http://i.stack.imgur.com/sUjYY.png) **view**   * sets up & manages the UI possibly requiring the requesting of data from the presenter   * sets up controls to alter what is displayed, possibly requiring the requesting of data from the presenter **cache**   * contains a record of some fetched data in data objects   * has a .store() method for storing data in the cache   * has a .retrieve() method for retrieving data from the cache   * access for storage and retrieval is available to the model and the modifier (acting as a faster intermediate location for the sharing of information than the server) **presenter**   * handles requests for formatted data from view   * requests data from Model (passing a callback for completion) formats data for presentation and calls view callbacks **model**   * handles requests for data from presenter   * requests data from cache (cache.retrieve())   * if data not in cache, requests it from server and then stores it in cache (cache.store())   * data passed back to presenter via callbacks **modifier**   * handles requests from view for modifications to data   * specify post, put and delete request types   * only support specific types of request which may be handled separately (eg settings)   * stores new data in cache (cache.store())   * pushes data to the server   * calls callback about the success of data storage This is quite big project and there will be a number of others working on it so it would be good to get it right from the off. **edit 1** The cache.store() and cache.retrieve() methods both only receive the information required to refer to the data in the cache, but do not specify how it is stored. The cache methods use this information to respond with or store the correct data, but the internal structure in which the data is stored is kept secret.


title: How do I make multiple calls to a web service without taxing that service heavily? Scaling question

text: is there a good pattern for how to send multiple calls to a web service but without taxing it and ensuring the data is sent back? I don't know enough to correctly describe the problem to even start googling it properly - current google results compare streaming vs. non-streaming wcf answers? Scenario: I am working on an app (I'm a jr. dev.) that needs to gather information from several sources about a 'customer' and the domains they own Technical: for one of the sources, I need to send a string array of domains to a web service and this web service returns an entry for each domain name, but this list of domain names will be thousands long - I would like to attempt to divide this list into bite-size chunks (1k domain names each) and then... queue them up to send to that web service, but ensure the web service doesn't skip one PseudoRequirements: Consumer of web page does not care how long it takes, but would like a list of results up front that does not require pagination to navigate. Current Theory: Should I take my massive 30k list, break it into 1k chunks, stuff each 1k-sized chunk into a 'request' object, assemble those 'request chunks' into a 'request chunk list' and iterate over that list (sequentially / blocking, so I don't strangle the WS) and for each 'request chunk' get back a 'response chunk' assemble those into a list, and then pass that list back into the front end for viewing? is this a viable method? is there a better way to queue items? Does anyone know off-hand any useful articles for this sort of queuing? are there any 'gotchas' or additional items to consider before I attempt my first pass? Additional Edits: -I do not have full control to the receiving service, I can not view it's code and the developers that manage it are... less than responsive to email. I do not currently know the stress testing limits of the web service. I emailed the owners of that component but have yet to receive a response - I was going to work up my design while I waited on them.


title: How to capture "Display advertisement" use case?

text: What kind of use case it would be for to "show ad in part of the view"? Who could be the actor to relate with? User or System? As user has no specific goal to see ads, i am wondering what is the best way to capture this in use case diagram? Any assistance will be helpful


title: Binary data storage scheme (saving user-uploaded files)

text: In our app we are currently saving binary data to the database (terrible, I know; but this is legacy stuff and it wasn't my decision). We're trying to migrate this data out to an external device and I'm trying to come up with a scheme to save these files. We have multiple tenants, I'd like to have a directory per tenant. My scheme for that is to build path using the first-three letters of the tenant. So if you had a tenant called `apple`, its files would be at `/a/p/p/apple`. Within these directories, I will save the files. For the files, I want to generate a random 6-character alphanumeric name (only lowercase characters for the time being because internal reasons). So if we generate a file name called `6a8jxo`, it will stored as `<tenant>/6/a/6/6a8jxo`. With this strategy, each tenant can have a maximum of approximately 916 billion unique files (not that we're attempting to save that many), with a maximum of 46,656 files per directory. If I go for a 5-character name, we will have a maximum of 60.5 billion unique files with 1,296 files per directory. Are there any drawbacks to this approach? I realize that certain directories may only contain one or two files, but in my mind that is not a huge problem. My colleague doesn't want to do it this way; he wants to use an autoincremented field in the database and then base the directory structure on the hex-value (I assume 32-bit) of that instead of using the tenant. With his strategy the hex value would be used as follows: the file will be stored in the directory located at `<tenant>/aa/bbb` where `aa` is the first two characters (most significant nibbles) of the hex value, and `bbb` is the next three. His reasoning is that he only wants to create new directories when one fills up instead of having numerous, partially-filled directories. This approach introduces numerous difficulties on the code side of things and I don't see having completely-filled directories as an argument that justifies the extra effort required to do this. Are there any other strategies or approaches I haven't considered?


title: Is there a Django reference?

text: I am new to Django. I have found the official topic guides https://docs.djangoproject.com/en/1.3/ an excellent place to learn from. But now I am in a place where I need quick reference to see what methods an object has, what arguments it takes, what it returns etc, kind of like the Python docs or Java docs. More of a reference than a tutorial. The official docs are tutorial style and do not necessarily have reference to all the methods. Am I missing something here? Do the Django official docs suffice for everyone?


title: Why are all desktop environments but KDE using GTK?

text: I recently did some hacking with Qt, and found it quite pleasant. Then I switched distributions on my laptop a couple of time, and noted that only KDE is using Qt, all the others are using the Gnu Image Manipulation Program Tool Kit. GTK is primarily a widget toolkit, although Windows and Mac ports do seem to exist. Not sure why one would build a DE on top of a toolkit for an image editor. Qt more of a cross-platform framework including threading, networking, and other non-GUI features. I heard licensing is considered a problem. Did I just answer my own question, or are there other things besides getting all zealotty about freedom? **update** I'd like to clarify that I'm not after opinions, but _observations_. "Qt is not real C++" is an observation, as is "GTK has been general purpose for a very long time". Besides, > But software and programming isn’t always a hard science, either. Once you > get past the does this code compile or not questions, you’re dealing with > issues of best practices, experiences, and behaviors. Perhaps because our > communities have become so accustomed to getting quick, accurate, and timely > answers, they feel that even a subjective Stack Overflow is better than the > alternatives. So much so, that our fellow programmers created a sister site > specifically for their pent up subjective questions. Take one heaping pile > of subjective questions, bottle it up for over two years and… kablooey!


title: How to dissuade a customer who just learned a technology and wants to use it everywhere?

text: My customer recently discovered what is URL Rewriting, without completely understanding what it is, how it works and the pros and cons of it. Now, he asks for lots of strange changes in actual requirements of current projects and changes in old projects in order to implement what he believes is URL Rewriting. **On one hand, I'm annoyed being asked to do things which doesn't make any sense** instead of doing real work. **On the other hand, I can't tell my customer that he doesn't understand anything in the subject** despite his interest in it. I think many people have had situations when their manager or their customer just learned a new buzzword or a new technology, and he loved it so much than he wanted to use it in every project, everywhere, rewrite the whole codebase just to use this new thing, etc. Also, I've recently read something related on Programmers.SE where people told about their experiences when there was a huge buzz around XML, and some managers would ask to introduce XML in every project just to show to everyone that they have used it. So those who have been in similar situation, how have you managed it?


title: Is there any circumstance in which a strict waterfall project can succeed when requirements are not clearly defined?

text: I can not see how a software project can make any meaningful progress under a waterfall methodology if the requirements cannot be clearly stated from the outset. Am I missing anything?


title: How often to release in Scrum sprint

text: How often to you release during a sprint. Only at the end of the sprint or every time a feature is ready. And how to you handle bugfix releases?


title: Parameterize Agent Based Simulation (OOP-Question)

text: I'd like to hear my fellow programmer's thoughts on the issue of parametrizing agent based simulations: Consider:   * Simulation core, including geometry, collision tests, some rules   * Different agents (modelled in OOP-fashion: has-a, is-a, abstract interfaces)   * Agents have different sensors, different actors, different controllers, ... All connected together by references/pointers and accessed using abstract interfaces. So essentially, each agent is composed of an ownership tree (agent owns sensors, controller, actors), superimposed by a dataflow-graph (sensor connected to controller, connected to actor). The tree, the graph plus the parametrization of the things together form a **simulation setup**. Running a simulation amounts to:   * Read in simulation setup   * Instantiate a bunch of objects, parametrize and connect them together to form the tree and the graph   * Run simulation   * Output some data (statistics, signals, whatever) The question is how best to save the simulation setup, and how to instantiate & parametrize stuff. Requirements (some of them conflicting):   1. The parametrization should probably be structured along the ownership tree, as it feels most natural.   2. A lot of times I'd like to instantiate a bunch of similar agents with just the 1 or 2 parameters changed between instances. That needs to be easy.   3. I'd like to keep parametrization and code close together. When experimenting with algorithms that are affected by parametrization, I wouldn't want the changes to be spread out over too many places.   4. Conversely, I'd like to keep parametrization out of the code, so that it's easy to automate simulation runs in order to systematically sweep through parameter spaces.   5. Parameters have meta-data: type, value range, physical unit, textual description, logical dependencies (e.g. if you specify X you must not specify Y)   6. Parameters not only affect data (member variables) but also code (usage of a particular specialization of the abstract base) * * * Now my colleges and me are tasked with building a new agent-based simulation:   * Do you know any frameworks / libraries / techniques?   * Are any patterns applicable? Best practises?   * Meta-programming?    * Abandon OOP altogether? Looking forward to your thoughts.


title: Is it safe to download VS11/.NET4.5 beta and still deploy to servers with .NET 4.0?

text: I've been wanting to try out VS2011 and .NET 4.5 beta, but the upgrade path is confusing at best. If I understand what I've read, the .NET 4.5 framework overwrites the .NET 4.0 libraries on your local machine, so libraries such as mscorlib.dll and System.dll will be replaced with the 4.5 version - fully backward compatible, but still different. If I'm developing ASP.NET sites with VS2011, and assuming I don't use any of the new 4.5 features in the code, do you know of any issues I might have by deploying to a web server with only the .NET 4.0 framework? I wouldn't expect any problems since it's the same CLR, but I'd like to know for sure before I do it. There's always the option of keeping a separate virtual dev machine for 2011/4.5 so that I can develop on 4.5, but go back to my original 4.0 machine to compile and publish, but I'd rather not go that route if I don't have to. Thanks


title: Should I include not-yet released projects on my resume/CV?

text: I finished a website project with new technologies such as HTML5 and CSS3. But my company will not let it go to production. They plan to launch the new site in their new project version function. Should I include such a non-yet-online project on my resume/CV?. Maybe with an additional explanation such as "this project is not released"?


title: Why is the main memory for object allocation called the 'heap'?

text: Has anybody got an idea why the area of main memory where objects are allocated is referred to as the heap. I can understand the rationale for that of the stack LIFO but would like to know what the rationale is for the 'heap' name.


title: Should my login logic be part of the controller or a service in MVC webapp

text: I'm using Shiro as my security manager for a Spring MVC web application. The login basically happens in these lines:               Subject user = SecurityUtils.getSubject();     user.login(new UsernamePasswordToken(username, password));      Where should I put this logic? `login()` can throw exceptions if the requested user doesn't exist or wrong password was provided, etc. Should I call the code from my controller and do the error handling there or should I call it from my service layer, catch exceptions and rethrow my own up to the controller?


title: Is there a graph with FOSS licenses detailing what can be linked with what?

text: I'm looking for a chart like this: ![alt text](http://i.stack.imgur.com/MmRTg.jpg) Basically something that tells you whether an app with a given license can be linked with a library of a given license. Does such a thing exist?


title: Dealing with a fundamental design flaw when you're new to the project

text: I've just started working on an open source project with around 30 developers in it. I'm working on fixing some of the bugs as a way to get into the "loop" and become a regular committer to the project. The problem is I think I've uncovered a fundamental design flaw that's causing one of the bugs I'm working on. But I feel like if I blast this on the mailing list I'm going to come off as arrogant, and some of the discussions I've had about the issue are butting heads with some of the people. How should I go about this?


title: Easiest language for simple Windows applications for novice Windows programmer?

text: Expertise: 11 years PHP programming I'd like to get into simple Windows programming for a kiosk project. What language should I choose? **My criteria:**   * easy to learn, "higher"-level language (e.g. not C++, I don't have a year to learn this)   * quick to get up-and-running (that's what I loved about PHP)   * well-documented & lots of community resources   * easy GUI creation   * client wants windows machines so Linux is not an option **What I've gathered from other Stackexchange answers and Google, but have no experience using:**   1. QT + Python (wish PHP-Qt was more mature -- it doesn't seem to have much of a community)   2. C# (seems like overkill for a simple kiosk)   3. Firefox + kiosk extension + AMP for GUI, and macro software to manipulate windows, files, lower-level stuff.


title: SQL Query syntax - formatting?

text: I'm looking at a very large (5-6 digit LOC), very complex, code-base, full of interacting bulky, interdependent, views and stored procedures (multiple 4-5 digit count silos). The source SQL has been touched many times, by many different people, and no formatting constraints have been enforced. This led to wildly differing formatting for SQL, even within single stored procedure/view definitions. The code continues to be worked on by several groups of, mostly, senior programmers, and sees a steady stream of small changes and improvements. * * * Under these conditions: a. what is a sane standard to conform to for formatting (eg, should we use all caps for keywords? seems like the small benefits from having so many programmers not have to press Shift actually add up to significant time/cost savings) b. is it worthwhile advocating for a major refactor to standardize the formatting (ie, is the cost of training a large body of programmers/changing their behaviour/ill will at enforcing a new constraint worth the benefit in the long-term?)


title: Source code for TCP/IP stack

text: Am looking for an open source code for the TCP/IP stack. An explanation along the lines of the stack would also help me in understanding the different modules and their interactions. I tried searching but there is very less information relating to just the TCP/IP stack.


title: Naming objects and properties clearly without exposing implementation details

text: I'm re-architecting an iOS mobile app that consumes an API with somewhat haphazard and oftentimes slow performance. The reason for the slowness is because the API is actually a layer on top of a variety of other platform- level services, some of which run slowly. You then get into the weakest link type of situation where the time it takes for the API to respond is bound by the slowest lower-level service response. When consuming the API I'm getting dealing with an object, let's call it `Foo`, that I display in a table, and also on a detail screen as necessary. A trade-off made by the API designer/implementer was to provide a call to get a list of `Foo` with some specific properties omitted (getting these properties for more than 1 or 2 objects at a time is very slow) and a "detailed view" call to provide a single object with all the properties filled in. The initial model schema had two model objects `Foo` and `FooDetails`. Feeling that this exposes unnecessary implementation details, I've merged both `Foo` and `FooDetails` into `Foo`, but a way to easily represent whether `Foo` is complete or not is still needed. (Meaning does `Foo` have extra properties present or not.) The best I could come up with was an enum:               typedef enum : NSUInteger {              ELYFooAbridgedState,         ELYFooCompletedState          } ELYFooCompletenessState;      I did not want to go with a `BOOL` due to the possibility of multiple "in between" states in the future as some lower level services are tuned. Can anyone provide an alternative naming or representation for this situation? Are there drawbacks w.r.t. to future proofing when taking this approach? This may the only time it's possible to do a ground up refactor of the app's model schema entirely, and I'd like it to be as resilient as possible.


title: When you use inheritance to reuse code, do you find it too tricky that it swallows the benifits of reuse?

text: I've been coding for about 8 years, however I still find inheritance is too flexible and sometimes it makes you totally confused with the code you have written. One simplest example would be:               abstract class AClass {         protected void method1() {             if(check()) {                 do1();             } else {                 do2();             }         }         protected abstract void do1();         protected abstract void do2();     }      The intention of the class is that people can implement do1() and do2() so that some further logic can be done, however sometimes people decide to overload method1(), and then things become complicated immediately. I find only in strategy pattern, code is reused well through inheritance, in most case the designer of the base class know its subclasses very well, and that inheritance is totally optional. I have a class that's inherited by 4 classes - an IoHandler, and it's subclasses for server side, client side, edge server, origin server, and it begins to drive me crazy. I was always in code refactoring, I always came out with ideas I think would work and then were proven not. It's said that human brain can only hold 7 pieces of information one time, am I carrying too many?


title: Writing documentation for well understood methods like equals in Java

text: Is it a good practice to write comments for widely known methods like equals, compareTo etc? Consider the below code.                /**      * This method compares the equality of the current object        with the object of same type      */     @Override     public boolean equals(Object obj) {                         //code for equals               }         My company madates to enter comments like the above.Is the above Javadoc comment required? Is it not obvious and well understood what the equals method and the likes (compare,compareTo) etc does? What are your suggestions?


title: How to make ASP .NET MVC website have a continuous process running?

text: This website is supposed to be a game where the players have some 'buildings' and these buildings produce resources. E.g. an iron mine may produce 30 pieces of iron ore per minute and automatically add it to the user's inventory. It doesn't matter whether the user is online or not, it should be running 24/7. So when the user does log in to their account, they will see their stack of iron ore has built up depending on how long it has been. Some pointers in the right direction would be greatly appreciated :)


title: What factors should I be looking at to increase performance in image resizing?

text: I'm setting up a web app in which people will upload images. Once uploaded the images will be watermarked then resized multiple times (Thumbnails, different sizes etc.) and finally uploaded to Amazon S3 for storage. The web app is written in Python with the Tornado framework, I don't really want to lock up the Tornado threads with the image processing so I'm going to send it out to a seperate script (and possibly even seperate servers) using Gearman (I've developed an async-gearman client for Python/Tornado). One of the advantages of Gearman is that it's possible to launch jobs in multiple languages, so the actual processing and uploading of the image could be done in ether Python, Ruby, PHP, Perl, Java, C, or something else. This leaves the question, is one better for the job? Are there certain libraries only available for specific languages that are especially good at image resizing? The most important thing will be performance: we'd like to be able to run as many jobs on a server as possible. Are there other factors I should be looking at? I'd prefer to stick with Python, Ruby, or PHP because that's what I'm familiar with but if the performance gain from doing it in Java/C is good enough I'd be okay with implementing it like that. I'm **not** looking for code examples, I can find those myself, but I'd like to know if there are any big differences between the image processing libraries. I know PHP probably has the easiest to use wit GD, and I've used a couple of the Python libraries before and they seem okay. I've never done anything with images in Ruby.


title: Dependency inversion always includes dependency injection?

text: This is a question on a home work. I've been up and down my notes and I can't even see how the two are related. Googling this gives me questions/answers on one or the other, but never both.


title: MVVM and service pattern

text: I'm building a WPF application using the MVVM pattern. Right now, my viewmodels calls the service layer to retrieve models (how is not relevant to the viewmodel) and convert them to viewmodels. I'm using constructor injection to pass the service required to the viewmodel. It's easily testable and works well for viewmodels with few dependencies, but as soon as I try to create viewModels for complex models, I have a constructor with a LOT of services injected in it (one to retrieve each dependencies and a list of all available values to bind to an itemsSource for example). I'm wondering how to handle multiple services like that and still have a viewmodel that I can unit test easily. I'm thinking of a few solutions:   1. Creating a services singleton (IServices) containing all the available services as interfaces. Example: Services.Current.XXXService.Retrieve(), Services.Current.YYYService.Retrieve(). That way, I don't have a huge constructor with a ton of services parameters in them.   2. Creating a facade for the services used by the viewModel and passing this object in the ctor of my viewmodel. But then, I'll have to create a facade for each of my complexe viewmodels, and it might be a bit much... What do you think is the "right" way to implement this kind of architecture ?


title: How to create single integer index value based on two integers where first is unlimited?

text: I have table data containing an integer value X ranging from 1.... unknown, and an integer value Y ranging from 1..9   The data need to be presented in order 'X then Y'. For one visual component I can set multiple index names: X;Y   But for another component I need a _one-dimensional integer_ value as index (sort order). If X were limited to an upper bound of say 100, the one-dimensional value could simply be X*100 + Y.   If the one-dimensional value could have been a real, it could be X + Y/10. But if I want to keep X unlimited, is there a way to calculate a single integer 'indexing' value from X and Y? [Added] **Background information** : I have a Gantt/TreeList component where the tasks are ordered on a TaskIndex integer. This does not need to be a real database field, I can make it a calculated field in the underlying client dataset. My table data is e.g. as follows:               ID    Baseline   ParentID      1       0          0     (task)      5       2          1     (baseline)      8       1          1     (baseline)      9       0          0     (task)     12       0          0     (task)     16       1         12     (baseline)       Task 1 has two baselines numbered 1 and 2 (IDs 8 and 5)   Task 9 has no baselines   Task 12 has one baseline numbered 1 (ID 16) Baselines number 1-9 (the Y variable from my question); 0 or null identify the tasks   ID's are unlimited (the X variable) The user plays with visibility of baselines, e.g. he wants to see all tasks and all baselines labeled 1. This is done by updating a filter on the table. Right now I constantly have to recalculate TaskIndex after changing the filter (looping through records with a counter). It would be nice if TaskIndex could be calculated on the fly for each record knowing only the _ID_ and _Baseline_ data in the current record (I work in Delphi where a client dataset has an OnCalcFields event handler, that is triggered for each record when necessary). I have no control over the inner workings of the visual component.


title: Entry level engineer question regarding memory management

text: It has been a few months since I started my position as an entry level software developer. Now that I am past some learning curves (e.g. the language, jargon, syntax of VB and C#) I'm starting to focus on more esoteric topics, as to write better software. A simple question I presented to a fellow coworker was responded with "I'm focusing on the wrong things." While I respect this coworker I do disagree that this is a "wrong thing" to focus upon. Here was the code (in VB) and followed by the question. Note: The Function GenerateAlert() returns an integer.               Dim alertID as Integer = GenerateAlert()     _errorDictionary.Add(argErrorID, NewErrorInfo(Now(), alertID))          vs...                _errorDictionary.Add(argErrorID, New ErrorInfo(Now(), GenerateAlert()))      I originally wrote the latter and rewrote it with the "Dim alertID" so that someone else might find it easier to read. But here was my concern and question: Should one write this with the Dim AlertID, it would in fact take up more memory; finite but more, and should this method be called many times could it lead to an issue? How will .NET handle this object AlertID. Outside of .NET should one manually dispose of the object after use (near the end of the sub). I want to ensure I become a knowledgeable programmer that does not just rely upon garbage collection. Am I over thinking this? Am I focusing on the wrong things?


title: Would it be hard to screen form submissions (e.g., comments) for non-words/non-sentences?

text: I've been thinking a lot lately about the need for better form security, and good ways to accomplish that. We currently use captcha codes to screen for bots, but that's annoying to users and may not work forever. I think that we need a more intuitive, organic system for screening bad comments/contact form submissions. One option that has come to mind would be trying to screen comments for things that are obviously not words, in addition to screening for duplicate comments. E.g., when a spammer on Facebook, Twitter, or a comments section is stopped from just posting the same thing a lot of times, they add garbled letters and or numbers somewhere in the post to make it "unique". If it was possible to screen out obvious not-text, this could be overcome. If you could go a step further, and screen out posts that obviously have words placed in for no reason except to make the post "unique", you could force the spammer/scam artist down to only use repetitive post options which actually make gramatical sense. At the very least, you could have posts be flagged for moderator attention if they looked similar but which just had random garbage added in for no reason. This would significantly reduce a spammer's ability to keep spamming, even across multiple accounts. Could it be possible to screen form field results for random word and number combinations, and words thrown in just to make a post "unique"?


title: Visitor stability vs instanceof flexibility

text: I am working on a GUI application which generates a configuration file. I have a class hierarchy for the configuration model and I use an object tree of that hierarchy in several different contexts. Currently, I use the Visitor pattern to avoid polluting my model classes with context specific code.               interface IConfigurationElement {         void acceptVisitor(IConfigurationElementVisitor visitor);     }      In an earlier version I used chains of `instanceof` conditions instead of the Visitor. Comparing the two approaches I see the following tradeofs. _Visitor_   * It is easier and safer to add new `IConfigurationElement`. Just add a new declaration to `IConfigurationElementVisitor` and the compiler generates errors for all visitor implementations. With `instanceof` chains you have to remember all the places you have to extend with the new configuration element. Basically `instanceof` violates the DRY principle as it duplicates logic in several places.   * The visitor pattern is more efficient than a chain of `instanceof`conditions _instanceof_   * The great advantage of `instanceof` is its flexibility. For example `instanceof` allows me to define special solutions for different subsets of `IConfigurationElement` implementations which need to be handled similarilly in some cases. In contrast, Visitor forces me to implement a method for each implementation class every time. Is there a common solution for this kind of problem? Can I adapt the Visitor somehow, so I can provide a common solution for some cases?


title: Fernando J. Corbató's “Constrained languages”

text: For his 1990 Turing award speech, Fernando J. Corbató listed reasons why complex systems will inevitably fail. In his conclusion, he gives some suggestions for decreasing the probability of failure. He lists one idea as follows: > [U]se of constrained languages for design or synthesis is a powerful > methodology. By not allowing a programmer or designer to express irrelevant > ideas, the domain of possible errors becomes far more limited. What does he mean by "constrained language?" For a moment I considered constraint programming. However, constraint programming is about restricting the program's solution space. It is a tool that empowers a programmer. The feature Corbató is referring to seems to be something which actually restricts the programmer, or at least makes her more inclined to write terser code. My second thought is that he is referring to conservative programming languages. Corbató received his Turing award for work done in the 1960s and 1970s. It's my understanding that he dealt with a lot of punch cards. I have never seen a punch card, so I certainly don't know how to program one, but I might guess that punch card programming is extremely liberal. I suspect the notions of type checking, static analysis, and so forth simply didn't exist. So, is Corbató perhaps referring to the idea of languages that restrict the developer from making dumb mistakes? This doesn't seem to be the case, either. Safety checking and data modeling have nothing to do with terseness, which is what he seems to be talking about when he mentiones "not allowing ... irrelevant ideas."


title: Descriptive Locking and Concurrency

text: I'm thinking about how one would go about designing a descriptive concurrency model for an OOP language that helps simplify concurrency scenarios for programmers (no easy task, concurrency is hard). I've read a bunch about software transactional memory, the actor model, immutability etc etc but they don't exactly seem to offer an easy model either, and while functional programming is great for some concurrency and parallel scenarios some times you simply need to mutate some kind of state. While locking is considered bad by some atleast it's fairly easy to reason about on a basic level (until you get into deadlock territory that is) Anyways, one of the ways I thought programmers could somewhat easier handle multi-threaded scenarios was that each class is responsible for it's own thread-safety on a per method/property basis. Ie other classes can only access properties and methods, they can't really lock on anything specifically, nor should they have to. One way to make it easier though would be to annotate methods and properties for concurrency with their indent rather than locking specifics. The compiler will then try to deduce the most performing lock from that. So assuming atomicity what do you think good annotations would be? and what are potential problems with this approach, I'm aware that it can't solve all scenarios (like transactions) but it should help the compiler enforce the programmers intent, and might even be able to warn on potential deadlock/racing scenarios Here's some of the attributes i thought of so far (also note that none of them are mandatory but strictly compiler "hints")               <property preference="none|read|write|fair">             <get access="free|exclusive|shared"             load="unknown|many|few"             duration="unknown|nano|brief|long"/>              <set access="free|exclusive|shared|upgradeable"             load="unknown|many|few"             duration="unknown|nano|brief|long" />          </property>      So for instance if get and set was set to shared access you might end up with an reader-writer lock. (do I need an attribute to control visiblity.) If duration for a write was set to nano perhaps it would use a spinlock. If there are many reads and few writes perhaps the compiler would use a different lock that if there were many writes and few reads etc etc. Methods can be coupled into read/write pairs similarly to properties (in case you need more than one parameter). For numeric properties that typically update based on some condition of it's value I was also thinking that instead of passing just a new value, you could pass an operator and an amount. That way you could lock, calculate the new value, see if it meets some internal condition and in that case update. Anyways, I'm struggling a bit coming up with good attributes/notations that are somewhat easy for a programmer to wrap their head and reason about, any help and feedback deeply appreciated. Sorry for the long rant, as I said this isn't an easy topic :)


title: Formal term to web-ify a piece of existing software or program or a module?

text: There is a software we run as a windows service. Its currently not designed to take a huge load. So we kind of need this service to be hosted over http so that multiple clients can make use of it. Its not the whole windows service as such, but some modules it uses. Those modules are currenly not designed to work as "web service" (generic sense). What would be the formal word for this?


title: category theory based language

text: It may sound naive, but is there any programming language, or research thereof, based entirely on category theory? I mean this as opposed to embedding CT concepts as an additional feature (like for Haskell or scala). Would it be too abstract or too complex as an approach, or are there any known reasons that makes it impossible or impractical? I have only a relative understanding of the theory as related to programming, so please give me some explanation if the question doesn't makes sense at all EDIT What I mean is to define a language where categories are first class concepts, instead of let's say types. E.g. haskell is defined in terms of _types_ and _functions_ over those. Does it makes sense to design a language where fundamental entities are _categories_ and _arrows_? From there you would, for example, define algebraic operations on numbers as individual "intances" of the proper algebraic category (ring, monoid, group...) instead of starting from standard integer/float operations and defining the corresponding categorical typeclass. Does it makes sense?


title: Want some architecture input to help with current requirements and future (unknown) requirements :-)

text: **BACKGROUND:** I am starting to architect a web project using asp.net mvc. I'm going to use a very common architecture where I have the following layers:   1. Service    2. Biz   3. Data   4. Domain The Service layer interacts with the Biz, Data and Domain layers. The mvc controllers will have the service layer injected into them using a DI framework. The controllers will need to be aware of the Service layer interfaces and will reference the Domain objects (POCOs). The front end will be HTML5 + Javascript. I have been told to keep in mind we need to expose _portions_ of this website to mobile devices. The _portions_ to expose via mobile devices is to be defined :-). When rendering the site I can simply have a mobile layout that renders to a mobile device. But one thing management told me is mobile users might want additional functionality the website doesn't expose. Maybe they want to access a feature that only a native mobile application can provide. Hey, I don't make up these requirements, this is what I was told :-). **THOUGHTS:** My service layer is the gateway to storing objects in my database. For any potential native mobile devices I was thinking about using the Web API to wrap my service layer. What I want to do NOW is focus on on my asp.net mvc application and only worry about native mobile apps when those requirements become more defined. **QUESTION:** would it provide any benefits to code the Web API layer now and have my mvc controllers use it? * * * Pros for creating the Web API now   1. It will be coded and ready if / when a native mobile app comes online. Cons for creating the Web API now   1. It is overhead that is not needed, especially if I host the WebAPI in a seperate process or another site besides my original asp.net mvc site.   2. The technology is fairly new and enhancemens will be forthcoming. If i wait until later some of the issues will be fixed.   3. Who knows, my users may never want a native mobile device and the feature is never utilized.   4. The code becomes more complex because of having to maintain the web api layer now. I'm looking at not worrying about the Web API layer for now and simply coding it when necessary. Typically I don't worry about writing for functionality that is yet to be defined. But I thought it might not hurt to ask, you never know what some brilliant maverick programmer is doing out in the wild :-).


title: Does the use of personas in Agile have any value during implementation?

text: This is about the use of personas, primarily in the agile development realm. What value, if any, do personas give during implementation?   On agile modeling, the discussion about personas remains in the context of requirements investigation.   On wikipedia, the benefits are described to "assist with brainstorming, use case specification, and features definition." I'm familiar with personas in use while writing user stories such as the following: > As Willow, I want ordering a combo meal to give me the option to select > alternate sides.   >  As Xander, I want the default side to be selected when I order a combo > meal. In these examples, Willow is the nutrition-conscientious user of meal-ordering software and Xander is the hungry, impatient user that thinks "fast food should be _fast_." When coming up with these requirements, it may have been helpful to have the personas in mind. I imagine a possible discussion: > Person 1: Willow needs to have more options than fries for the combo meal, > otherwise she would never order a combo.   >  Person 2: But Xander doesn't want to have to sift through different options > when ordering a combo! He just wants fries and he'll probably always want > fries. This discussion may have created the two requirements above, but once the requirements have been created, why do we mark each requirement with a persona? I wouldn't code the 'default side' requirement any differently knowing that it is for Xander. What value does retaining the "As Willow" and "As Xander" starts to the requirements once they have been written? What value does the persona give to the one who implements the requirement?


title: Is there any hard data on the (dis-)advantages of working from home?

text: Is there any hard data (studies, comparisons, not-just-gut-feel analysis) on the advantages and disadvantages of working from home? My devs asked about e.g. working from home one day per week, the boss doesn't like it for various reasons, some of which I agree with but I think they don't necessarily apply in this case. We have real offices (2..3 people each), distractions are still common. IMO it would be beneficial for focus, and with 1 day / week, there wouldn't be much loss at interaction and communication. In addition it would be a great perk, and saving the commute. * * * Related: Pros and Cons of working Remotely/from Home (interesting points, but no hard facts) * * * To clarify: it's not my decision to make, I agree that there are pro's and con's depending on circumstances, and we _are_ pushing for "just try it". I've asked this specific question because (a) facts are a good addition to thoughts in arguing with an engineer boss, and (b) we, as developers, should build upon facts like every respectable trade.


title: Extension objects pattern

text: In this MSDN Magazine article Peter Vogel describes Extension Objects partten. What is not clear is _whether extensions can be later implemented by client code residing in a separate assembly_.   And if so _how in this case can extension get acces to private members of the objet being extended_? I quite often need to set different access levels for different classes.   Sometimes I really need that descendants does not have access to the mebmer but separate class does. (good old friend classes) Now I solve this in C# by exposing callback properties in interface of the external class and setting them with private methods. This also alows to adjust access: read only or read|write depending on the desired interface.               class Parent     {         private int foo;              public void AcceptExternal(IFoo external)         {             external.GetFooCallback = () => this.foo;         }     }          interface IFoo     {         Func<int> GetFooCallback {get;set;}     }      Other way is to explicitly implement particular interface. But I suspect more aspproaches exist. **Update 1**   New Peter's article makes it a bit clearer.