When to use repository pattern

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


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

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


When do I need web services?

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


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

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


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

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


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


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

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


How to manage product backlog/user stories

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


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

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


How to solve conflicts with another programmer

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


Newbie, deciding Python or Erlang

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


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

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


When to use JavaScript instead of Ruby in web development?

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


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

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


Working with shader code

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


When should a database table use timestamps?

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


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

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


Refactoring - Utility classes behavior under a common interface

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


Is there an Auto Generator for DataContracts?

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


Convert letters to numbers

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


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

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


Coaxing requirements out of business people?

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


When and why should one create classes at runtime?

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


What's the difference between recursion and corecursion?

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


Aggregate Boundary repository/service design

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


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


Continuous Delivery: Kanban, SCRUM, or other?

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


Do you write titles in code comments?

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


Best practices for using namespaces in C++

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


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

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


Difference between these 3 manager roles

Roles:   * Development Manager   * Program Manager   * Project Manager I have read a bit and independently I understand them well enough. However when you combine them, it seems to me that some responsibilities overlap and it becomes uncertain who is responsible for what. Does anyone have a clear way of defining how each role differentiate from the other? Or mainly which tasks are exclusive to each one? I want to avoid overlapping of responsibilities. I know there are other similar questions on the matter, but none exactly the same... Thanks EDIT: This 2 questions help a little, but still can't quite place each role when pushed together: What is the difference between a Program Manager and a Project Manager? The Written Roles of Software Development Manager


How popular is ITIL in the rest of the world?

I am sorry if this question is not 100% Programming wise, I just didn't know where to ask. Consider yourself lucky if you don't know what ITIL is. You can understand from my tone I don't like it - I find ITIL the complete opposite of how IT Company should work, being too bureaucratic and complicated. In Germany, where I work, it seems to be very popular, and I have been asked in several job interviews if I know ITIL. Do you know popular is it in the rest of the world? Should I worry about ITIL or I can snub it? I must also ask my European colleagues - Why do you think is ITIL so popular? Is there a strong **empirical** evidence that ITIL does work?   By empirical, I mean not personal experiences of the kind "We are a company that is working with ITIL...". I can hardly imagine a multi-million dollar company like Apple or Google work with ITIL, but I can also hardly see how it can benefit small companies...


Do VMs use one stack for everything?

Most VMs have a "call stack" to keep track of where to return from each function that was called. This is often simply regarded as "the stack". However often a stack is needed for operations that aren't related to function calling, such as performing arithmetic. My question is: is the same stack (i.e. the call stack) used also for these kinds of operations? Or do operations such as performing arithmetic use a different stack? (I'm talking about most VMs).


Light-weight visual requirements tool (combination of mockups and use cases)

For my team, mockups are the primary artifact for development and the requirements process. We use balsamiq mockups for confluence. We also write use-cases to point out the workflow and for adding information such as how the system will respond to an action, UX requirements and other references. It's not ideal, because the documents are separate. We're looking for a tool that's entirely mockup-based, with structured contextual texts to the side for requirements, system response, etc. (note: I know I can add annotations, what I'm looking for is structured entry and structured presentation of requirements). It should also visualize the flow and states of pages in the form of a storyboard. Does such a tool exist and could you recommend one to me? Thanks! Rolf


A completely free and open programming language

With Oracle vs Google trial, it seems that Java is not entirely Open and free (as free software) as I expected. Although there exists completely free/open JVM, it's hard to know what is a copyright infringement with Java, and what is not. So I'd like to know if there is a completely Open and free language with open and free IDE (Eclipse-like) out there, Object Oriented if possible, and able to make window-based applications for the main OSs (Linux, Mac, Windows).


today's multi-device world for web development

With the huge explosion of mobile devices and addition of HTML5/CSS3, there seems to be a shift towards "responsive" designs (i.e., adapting to smaller screen sizes) which seems to be achieved using CSS3's Media Queries. My question is, given the current need of adapting to both desktop and mobile, is it common practice to actually organize two versions of your website (one for desktop and one for mobile)? Or is there just one version with different css files for targeting different devices and screens? Handling just cross-browser (ie6, ff3, opera9, etc...) HTML4/5, CSS2/3 was already hard enough, but now we're expected to handle cross-device (phone, tablet, etc...) as well, so my assumption is company's would create a separate project for mobile and redirect based on the user agent, but this is just a guess.


Programming vs Engineering

I am in high school at the moment and soon reaching stages where I would have to make choices. To introduce, I love programming. I had started learning programming a year ago and have some experience with ActionScript3 and Java + (the web languages like html CSS JavaScript. But php I have found a bit hard to understand). Other subjects which I absolutely love are mathematics, physics and chemistry. The professions related with these subjects that really interest me are engineering (piping engineer, mechanical engineer, electrical engineer etc.). People say to me that I should choose the profession based on my interests. But I have absolutely no preference of one over another. My choice really depends on the demand of these professions in future. So my questions are -   * Is the demand of programming going to degrade in future due to a excessive number of programmers in future? Or is it going to remain a profession in high demand.   * Is engineering going to lose its demand? Almost everybody seems to be going for the profession of an engineer these days and it is scary to think what will happen of the world with the number of engineers there are.   * Which profession is likely to remain well paid in future too?


Development setup for TDD. Is it correct?

This is how my team has it's development environment set up:   1. Each team member has a local development environment on their own computer, where they check out the code from a shared repository.   2. Every developer work in their local development environment, once they finished writing the code they commit back.   3. The code is then checked out to a staging/testing server with the same environment setup   4. If everything is OK, it will be pushed to a production server. We're trying to integrate unit testing and BDD (behavior driven development) into this setup and we'd like to use a continuous integration server (Jenkins) too. My question is where should we install this and where should we test the code?   1. Install the full testing stack for each developer: TDD tools + BDD tools + Jenkins?   2. Install the test tools only on the staging/testing server and only test code here once each developer made his/her code commit? How is your setup?


How to quickly try out Java code?

When I'm coding in Python and I want to try something out, I open IDLE of Python on the command line and am able to quickly try something out. Is there a similar way I could do that for Java? I have heard about Java "shells" (e.g. http://www.beanshell.org/). Has anyone tried them?


Implementing a Service Layer with MVC4 while honoring Single Responsibility

I'm trying to learn some best practices while I ramp up on MVC4. I have a solution with three projects:   1. Web: MVC stuff   2. Core: Data Model   3. Tests: Testing classes I'm now trying to add:   1. Services: Business Logic This will take logic such as "GetFilteredItems()" from my controllers and place them into a Service project, which depends on Core, and upon which Web depends. Nothing to do with HTTP requests. As I'm beginning to do this, I want to honor single responsibility and create one class per method. My questions: 1) Is this a good approach? 2) Say I need a GetFilteredItems method that takes an ID and returns a List. What's the convention here in terms of naming classes and methods? I can't have a class SampleClass with a method SampleClass() that returns something, right?


programming on handheld devices

This is a little vague. But I've tried to put the things to the point. As much as the handhelds (smartphones, tablets) are becoming extremely popular every passing day, What I wonder is, why there are no great programming tools for them? With great processing power of these devices, I don't think there's any problem in running compilers or even small scale IDEs on them. It is perfectly acceptable that conventional programming languages are very difficult to write with an onscreen small keyboard. I'd never want to write java on my Android. But are there any special tools or languages that are being developed in this direction? For exaple, I had an android application for BrainF**k that worked fine with limited number of symbols (though the language itself is boring enough for not using it). What in general is the scope of this area and direction of the research if any? Thank You. EDIT Note that I mean programming ON mobile devices. Not FOR mobile devices.


Centralised Integration framework

We are looking to centralise our Integration in our company and I'm wondering what sort of solutions other have for this and what the best way to approach it would be. At the moment we have different types on integration running different lanuages, different frameworks on different servers so we are looking to move them all to a single framework to make it easier to manage. Some of the current Integration includes:   * SQL Server scheduled tasks (on 3 or 4 servers)   * SQL Server Integration services (on 2 or 3 servers)   * Console applications (.NET on 2 Servers)   * Windows Services (.NET on 2 servers) What we are after is:   * 1 server that manages all integration jobs scheduling (so this only needs to be setup once and we always know where to find it)   * A job monitor that displays the history of jobs run (Much like the SQL Server Job Activity monitor)   * Jobs might need to run custom .NET code, here some sort of API might be used to allow for more flexibility over SQL Server Integration Services


Reading recommendations on development of web applications

For a programmer/cs student that wishes to dive into web development and freelancing... what are some good books/publications/portals/blogs? Please take into consideration also that I'm used to developing websites by googling my each step to find an example. I'm interested in technologies like php, javascript, jquery, ajax.. And maybe later: ruby and ror. It would be great if there would exist a book (or a collection of books) on web development that would cover the whole process of development, plus different techniques, principles, examples.. etc.


Is it acceptable practice to give an object a pointer to “the world”?

I often find myself in situations where objects need to communicate between each other. For example, a button might need to talk to various textboxes. Would it be proper to simply construct each widget with a pointer to the container for all of them? Would it be better to give it a pointer to a resource container map where the object can locate another object by string or something? This area has always been very vague to me. I could easily implement everything I want to do if I just constructed objects with pointers to containers of every other object, but that seems wrong. In the case of a widget, would it actually just be more proper if the widget knew nothing about the outside world and instead its action listeners were constructed with resource access? Thanks I understand that it is a bad idea but what are some solutions in these situations eg: good design patterns for gui oriented software? If a button's click needs to write a file, how can that be done in a clean way? Action Listeners? But where do they get created and by what?


How much web-design work should a web programmer commit?

I'm creating a website for a friend of mine, and the plan is to eventually solicit outside sources to take care of the overall design. So it's got me wondering, how much design should I be covering now? I'm primarily driven to just code the logic for the website and get everything _functional_ before I care too much about how it actually looks. My thoughts so far have been, I'll try to organize the code and create an effective skeleton to be drawn in. What's your thoughts? Is usability and functionality my only two concerns, or should I also be playing a preemptive role in the design decisions? How is this work typically split up in the industry?


Proving Yourself

I guess it isn't that common but occasionally there are some software developers who didn't actually go to college and just spent their teens hacking away at pet projects and learned enough to work out of high school. My question is if you were hiring a candidate how would you determine if someone who didn't go to a university but is claiming to be (more than)proficient and fully able to develop software just as well as a student with a degree? What do you look for? What would you want to see from this person that would put them at or above the level of a college grad when it comes to hiring?


How to deal with a dev who asks too many questions

I've recently stepped in to a managing position which of course involves overseeing other people's work, and guiding juniors. There's this guy who won't stop asking questions, and many times it's really basic stuff - which eats a lot of my time and breaks my in-the-zone mode. I tried the easy-going approach of sending him a link with "Let me Google that for you", but he only got excited about the joke, and didn't get the clue. Other times I'm just telling him I'm busy, and that he should go and research it himself. The thing is, when I wasn't in the office he did a decent job on his own, so most of what he's assigned with he can handle. The question is how can I make him filter the issues he comes to me with? I realize that I'm the professional authority he should be addressing when he needs help, I only wish he would do it on non-trivial matters.


Is the jRails Project something I should use?

The jRails project is a drop in replacement for the Prototype/scriptalicious helpers already a part of the Rails framework. Are your experiences with this project positive? Does it do what it says on the tin? Is it still being maintained or is this a bad choice if I want to do jQuery with RoR?


OOP - Composition, Components and Composites Example?

I've been reading a bit about OOP in relation to Composition, Components and Composites. I believe I understand the fundamental principle (not sure). Can someone please provide a code example of a person or car (both have many properties) using Composition, Components and Composites? I think seeing it in code would clear up the confusion I have regarding this pattern. Preferably in Java or PHP.


Ensuring transactional consistency with DDD

I am starting out with DDD and understand that aggregate roots are used to ensure transnational consistency. We should not modify multiple aggregates in one application service. I would like to know however how to deal with the following situation. I have an aggregate root called Products. There is also an aggregate root called Group. Both have Id's, and can be edited independently. Multiple Products can point to the same Group. I have an application service that can change a product's group: `ProductService.ChangeProductGroup(string productId, string groupId)`   1. Check group exists   2. Get product from repository   3. Set its group   4. Write the product back to repository I also have an application service where the group can be deleted: `GroupService.DeleteGroup(string groupId)` 1\. Get products from repository whose groupId is set to provided groupId, ensure count is 0 or abort 2\. Delete group from groups repository 3\. Save changes My question is the following scenario, what would happen if: In the ProductService.ChangeProductGroup, we check the group exists (it does), then just after this check a separate user deletes the productGroup (via the other GroupService.DeleteGroup). In this case we set a reference to a product which has just been deleted? Is this a flaw in my design in that i should use a different domain design (adding additional elements if necessary), or would i have to use transactions?


How can I get my progress reviewed as a solo junior developer

I am currently working for a 2 person company, as the solo primary developer. My boss gets the clients, mocks up some png design templates and hands them over to me. This system has been working fine and i'm really enjoying it. The types of projects I work on are for small - medium sized businesses and they usually want a CMS system. Developed from scratch i'll build a customised backend for the client to add/edit/remove categories, tags, products etc and then output them to the front end according to the design template handed to me. As time has gone on, the projects have increased in complexity, with shopping cart / ordering features and other common e-commerce type features. Again, this system has been working fine and i'm really enjoying it. My issue is my personal development as a programmer. I spend a lot of my spare time reading programming blogs, checking through stackexchange, reading suggested programming books (currently on 'The Pragmatic Programmer', really good so far), doing brain exercises (lumosity.com and khanacademy math problems), doing lots of physical exercise and other personal development type activities. I can't help but feel though, that I'm missing out on feedback, critique. My boss is great and never holds back on praise in regards to my work, but he unfortunately is either to busy to check my code, or to be honest, I don't think it's one of his specialties and so can't provide feedback. I want to know what i'm doing wrong and what i'm doing right. Should I be putting that much logic in the controller, am I modulating my code enough etc. So what I have done is developed a little 'Family Budgeting' app and tried to do it as cleanly and effectively as I currently know how. What i'm wanting to know is, is there somewhere I can submit this app, and have some seasoned developers provide feedback. It's not just a subsection of my code like 'codereview.stackexchange' appears to require, it's my entire workflow that I want critiqued. I know this is a lot to ask, and I expect the main advice given will be to look for a job within a team, which is certainly something I will look into later down the track, but for now I want to persist with my current employment situation, but just don't want to develop too many bad habits. Let me know if I can provide any further information to help clarify, or if this isn't the right place for this type of question I apologise in advance. Didn't want to use reddit as I felt this community fosters more well thought out responses.


Can I Put My Past Company's Project in my Resume?

I am building my resume now but I am unsure if I am allowed to put my past company's project in the Project's section of my resume. I am not planning on disclosing proprietary details, just the name and the description of the project (if the name doesn't count as proprietary). Thanks!


How do I convince my team to use smaller classes/methods?

Disclaimer: I'm a newcomer (this is my third day of work), and most of my teammates are more experienced than me. When I look at our code, I see some code smells and bad engineering practices, like the following:   * Somewhat inconsistent naming guidelines   * Properties not marked as readonly when possible   * Large classes - I noticed a utility class that consisted of hundreds of extension methods (for many types). It was more than 2500 lines long!   * Large methods - I'm trying to refactor a method which is 150 lines long. The latter two seem to be a real problem. I want to convince my teammates to use smaller classes and methods. But should I do that? If yes, then how? My team got a mentor from the main team (we're a satellite team). Should I go to him first? * * * **UPDATE** : Since some responses asked about the project, please know that it's a working project. And IMHO, huge classes/methods of that size are always bad. Anyways, I never want to piss my team off. That's why I asked - Should I do that, and if yes, then how I do that gently? **UPDATE** : I decided to do something based on accepted answer: because I'm newcomer, so I see everything in "fresh eyes" I will take note on all code smells that I found (position, why it bad, how can we do it better,...), but at the moment, I just try hard to gather respects from my team: write "better code", know people, know why did we do that... When the time is right, I will try to ask my team about some new code-policies (naming guidelines, smaller classes, smaller methods,...), and if possible, refactor some old code. It should work, IMHO. Thank you.


Best practice to prevent potential paying customers from creating many trial accounts

I have an idea for a web app, and I want to make it a freemium service. Those who sign up will have the ability to create 3 pieces of content for free and will be required to pay a premium to obtain the ability to create further content. Provided that the two account types will have identical behaviors except for the quantity of content, what is the best way to prevent these users from circumventing my pricing plan and creating tonnes of trial accounts? Have you thought about this before? What do you do on your web app? I could monitor email addresses, IP addresses, phone numbers, etc., but all of these are easily circumventable. Thoughts?


which input sanitization function is better?

apparently, some of our websites have been hacked by a hack bot. The reason: bad input sanitzation. Our boss is giving us this file to put on all our servers to secure them: http://pastebin.com/0gJ19TQG Personally, i just do this on my personal websites: `filter_var(mysql_real_escape_string($_POST['Nom']), FILTER_SANITIZE_STRING);`. So you tell me, which one is better and why?


Can you prototype a complex system change?

I'm currently in the process of redesigning parts of a large and complex application server to allow it to be distributed across multiple machines. I've been asked to provide a prototype of the redesign in a relatively short time period. I don't think it's possible to create a prototype of this; the changes are in existing code, and the changes are at such a low level that the system can only be in one of two states: working or not working. There's no middle ground. The changes have to be implemented all at once, because they all rely on each other. There's no way to partially implement all of the changes, the system won't work unless they're all fully implemented. At this point, I'm unsure of what to do. I know that it's hard for others to tell without knowing every detail, but on a generic level, am I right in that something like this can't be prototyped? Is there some way to prototype things like this that I don't know about?


REST Relationships Besides Parent/Child

This would seem to be a pretty basic question, but I can't seem to find appropraite guidelines for it. What is the "restful" way of `POST`ing a relationship between two entities that are not necessarily parent/child. As an example, consider customers and orders. One could create a customer with a `POST` to `/customer`. However, what is the best way to create the order? One example would be a `POST` to `/customer/123/order`, but what if the order isn't assigned to a customer directly, and could exist on its own (in the case of a web-cart that allows for "anonymous" checkout)? Is the right way, then, to do `POST /order?customerId=123` Further, consider the case that an order can be submitted separately from payments (let's say we are invoicing a customer). You could create the order (per either of the methods above), but how would we make the payment? `POST /order/123/payment` or `POST /payment?orderId=123` (if we assume that a payment can be made for something other than an order, and one might want to get information about an order/payment without knowing the specific customer).


Are certifications through O'Reilly worthwhile?

Other than being able to put "I know Python" on a resume, are the certifications from O'Reilly School of Technology (they are issued by the University of Illinois) any good for obtaining employment? I am interested in learning many of the topics covered by these programs and since they are fairly well-priced, I was thinking of going this route. However, I don't really want to do it if it's about as worthwhile as a degree from University of Phoenix. Does anyone know what effect these certs may have on obtaining employment vs not obtaining a certification, but learning on your own?


The need for source control software - Team Foundation Server? or something different?

Recently, Here at the company, more than one programmer was appointed in charge for a LightSwitch(C#) software development project and immediately there was a need of some sort of source control/sync. We have never used Team Foundation Server but we'd gladly use it if it's worth it.   * Is it the right tool to use for   synchronising code between   programmers?   * Does it have the needed features?   * Do you have any other tool in mind? (I have used TortoiseSVN but   it was too simple and 'texty' if you know what I mean, we need a   professional tool)   * What other features does Team Foundation has that we can use? (if you did not understand any of the above please ask me to clarify further)


Seeking LOC counter with estmated cost to write those LOCs

I had one (Linux only) and I lost it. I'd like another, either Windows or Linux will do. Please _don't_ turn this into a "such estimates are useless" discussion. I need ... something, anything ... to show that s/w development is not free. Even a wild guess is better than nothing. The last one I used said something like X lines of code - the average US programmer would take Y months to do that at a salary of $Z. Again, please don't tell me why I don't want it - because I do. Apologies for trying to fend off the noise before it even starts. Thanks in advance for any help.


Scrum: how to integrate work done by an overachieving developer out of band?

We have a "typical" SCRUM team and we commit to work for a sprint, and also maintain a backlog. Recently we have run into a problem of trying to integrate/handle the work of an overachieving developer doing out of band work (choosing to work outside of the normal working hours/sprint). To give an example, if the team takes in 50 points of work, let's say that they will complete all that work within the SCRUM framework by the end of the sprint and they and the company is happy. One of the team members decides to work on their own, on a backlog item, on their own free time. They do not check in this work, but instead save it (we use TFS and it is in a shelveset). How to handle this? A few of the problems ..   * During the next sprint this team members says the programming work is 99% done and just needs code review and testing. How do you deal with this in the SCRUM and agile methodology?   * Other developers complain about not being involved in design decisions related to these stories, since the work was done out of band.   * Our product owner is tempted to pull in this "free" work and the overachieving members is likely doing this on purpose in order to get more features into the product that the team otherwise would not be able to accomplish in the sprint(s). There is a view that this is breaking the "process". Obviously QA, UI and documentation work still need to be done on this work. I see a lot of discussion about not forcing a SCRUM team to work overtime, but what about a member of the team working above and beyond the expectations put forth during planning and execution of sprints? I would hesitate to reign this person in and say you cannot work extra (cautioning on burn out of course), but at the same time it seems to be causing some issues with certain members of the team (but not all). How to integrate work done by an overachieving member into the SCRUM and agile process for software development?


How using tab affects commands like diff

In the page at http://pear.php.net/manual/en/standards.indenting.php, it is advised to use space instead of tab as it causes issue with diff, patches. Here is the excerpt from the page. > Use an indent of 4 spaces, with no tabs. This helps to avoid problems with > diffs, patches, SVN history and annotations. So, my question is if we are using tabs everywhere, how it is going to affect these commands?


How to make hardware sizing sheet?

We build some software platform, and now we need to make hardware sizing sheet for the server-side piece of this software. So, I should prepare some mathematical model that, for example, given the number of concurrent users, can predict the number of physical servers or storage capacity or network bandwidth. How to make such model?


When forking an dual-licensed permissive/GPL project, can I drop one of the licenses?

Consider an existing project that is dual-licensed GPL + either MIT or BSD. Since it's dual-licensed, when I fork, can I pick one license in the fork? Or do my forked files need to continue to be dual-licensed? It sure would be simpler to track only one license.


Was it necessary to build this site in ASP.NET?

From what I'm told, the whole StackOverflow/StackExchange 'stack' is based on Microsoft's ASP.NET. SO and the SE sites are probably the most complex that I visit on a regular basis. There's a lot going on in every page - lots of different boxes, pulling data from different places and changing dynamically and responding to user interaction. And the sites work very smoothly, despite the high traffic. My question is, could this have been achieved using a different platform/framework? Does ASP.NET lend itself to more complex projects where other web frameworks would strain and falter? Or is the choice pretty incidental?


How to avoid to be employed by companies which are candidates to DailyWTF stories?

I'm reading The Daily WTF archives and especially those stories about IT- related companies which have a completely wrong approach of software development, the job of a developer, etc. Some stories are totally horrible: a company don't have a local network for security reasons, another one has a source control server which can only be accessed by the manager, etc. Add to it all those stories about managers who don't know anything about their work and make stupid decisions without listening to anybody. The thing is that I don't see how to know if you will be employed by such company during an interview. Of course, sometimes, an interviewer tells weird things which gives you an idea that something goes very wrong with the company (in my case, the last manager said I should work 100% of my time through Remote Desktop, connected to on an old and slooooow machine, because _"it avoids several people to modify the same source code"_ ; maybe I should explain him what SVN is). But in most cases, you will be unable to get enough information during the interview to get the exact image of a company. So how to avoid being employed by this sort of companies?   * I thought about asking to see some documents like **documentation guide** or **code style guidelines**. The problem is that I live in France, and here, most of the companies don't have those documents at all, and in the rare cases where those documents exist, they are outdated, poorly written, never used, or do force you to make things that don't make any sense.   * I also thought about asking to see **how programmers actually work**. But seeing that they have dual screens or "late-modern-artsy-fartsy furnishings" doesn't mean that they don't have people making weird decisions, making it impossible to work there. Have you been in such situations? What have you tried? Have it worked?


DDD and validation of aggregate root

Suppose an aggregate root : MailConfiguration (wrapping an AddressPart object). The AddressPart object is a simple immutable value object with some fields like senderAdress, recipentAddress (to make example simple). As being an invariant object, AddressPart should logically wrap its own Validator (by the way of external a kind of AddressValidator for respecting Single Responsibility Principle) I read some articles that claimed an aggregateRoot must validate its 'children'. However, if we follow this principle, one could create an AddressPart with an uncohesive/invalid state. What are your opinion? Should I move the collaborator AddressValidator(used in constructor so in order to validate immediately the cohesion of an AddressPart) from AddressPart and assign it to aggregateRoot (MailConfiguration) ?


Dependency injection: what belongs in the constructor?

I'm evaluating my current PHP practices in an effort to write more testable code. Generally speaking, I'm fishing for opinions on what types of actions belong in the constructor. Should I limit things to dependency injection? If I do have some data to populate, should that happen via a factory rather than as constructor arguments? (Here, I'm thinking about my `User` class that takes a user ID and populates user data from the database during construction, which obviously needs to change in some way.) I've heard it said that "initialization" methods are bad, but I'm sure that depends on what exactly is being done during initialization. At the risk of getting too specific, I'll also piggyback a more detailed example onto my question. For a previous project, I built a FormField class (which handled field value setting, validation, and output as HTML) and a Model class to contain these fields and do a bit of magic to ease working with fields. FormField had some prebuilt subclasses, e.g. FormText (`<input type="text">`) and FormSelect (`<select>`). Model would be subclassed so that a specific implementation (say, a Widget) had its own fields, such as a name and date of manufacture:               class Widget extends Model {         public function __construct( $data = null ) {             $this->name = new FormField('length=20&label=Name:');             $this->manufactured = new FormDate;                  parent::__construct( $data ); // set above fields using incoming array         }     }      Now, this does violate some rules that I have read, such as "avoid `new` in the constructor," but to my eyes this does not seem untestable. These are properties of the object, not some black box data generator reading from an external source. Unit tests would progressively build up to any test of Widget-specific functionality, so I could be confident that the underlying FormFields were working correctly during the Widget test. In theory I could provide the Model with a FieldFactory() which could supply custom field objects, but I don't believe I would gain anything from this approach. Is this a poor assumption?


New Job Over Budget

I recently started a new job as a contract developer, and my non-developer boss of about two weeks ago gave me the task to re-create an app from another language and developer that he will reuse with multiple clients (replacing the front-end), that I estimated would take longer than his estimate of 12 hours. Two weeks later, I'm 230% over-budget. I admit this was my 2nd web app, I had been a wordpress developer in the past, so I am somewhat new to code igniter, but not shabby php by any means. My boss hired me knowing this and I was clear that it would take longer than his 12 hours. He's seen me in the office on task for 2 weeks, he should be somewhat prepared for this bill. Do I expect the full amount of hours, or do I filter against how much of learned? Can I bill for research as a developer?


Which framework should a ruby beginner start with: rails or sinatra?

What is the best framework for start: rails or sinatra? I heard that sinatra is more flexible but rails has a lot of documentation and tutorials. What's your choice?


Is it okay to rollback code if your client refuses to pay you?

A friend of mine did some contracting work to add localization support to an existing mobile app. He was not contracted to add any other features or fix any already existing bugs. He has finished his work, but the client refuses to pay him because of an already existing bug that he hasn't fixed. The only card my friend has left is to rollback the server code to the state it was before he began working, which will probably break the mobile app and hopefully force the client's hand. Is this legal? Is there a better way to handle the situation?


Is it practical to use Twitter for service logs?

Recently my boss suggested that we post logs of our service that is hosted on Windows Azure into twitter. His idea is that it's conveniently readable and if Azure cloud fails logs persist. He also said, _lots of people do this_ , I Googled and couldn't find any data about this. Currenly my concerns are the following. First, perhaps twitter is not very convenient for logging something that can happen very frequently (for example, when our service role starts each instance writes tens of records over several minutes). Second, even if twitter EULA allows such use at this moment it might be changed in future to cut off tweets that occur too often to be human- originated. Is it practical to post service logs on twitter? What to consider if we implement this?


WCF hardware requirement

I read the hardware requirements of WCF in a book and two of them are the following ones:   * A DVD-ROM drive   * A 1024 × 768 or higher resolution display with 256 colors or more Why is there a requirement for the screen resolution, or to have a DVD drive? Perhaps, this requirement is necessary for Visual Studio to work. Am I wrong?


Is C++0x Compatible with C?

I have heard that there will be a lot of changes done in C++ because of the new standard (C++0x). My question is: What are the major changes, and will C++0x be compatible with C++ 98 and **C** ?


Chosing a parser for a code beautifier

I'm in the planning stage of making a code beautifier (similar to AStyle or Uncrustify) - originally I was going to just contribute to one of those projects, but reviewing their source led me to the conclusion that I have different design goals and that their source is written in a way that makes it difficult for an outsider to easily contribute. AStyle, for example, instead of building some sort of AST, uses over 100 state variables such as `isInComment`, `foundClassHeader`, `isLineReady`, etc. I'm deciding between using scanner and parser generators (such as flex and bison) and writing my own parsing system. Which would be a better approach? I've been through a compilers class in university, so I do have some experience with scanning and parsing theory. Below are the advantages I've thought of for each: **Generators**   * Arguably simpler/faster to develop   * Possibly more optimized than my initial stab at a custom parser, though a custom one might leave more room for improvement **Custom parser**   * Arguably easier to debug   * _Programmers_ seems to prefer custom lexers and parsers in past questions - "Anyone who wants a decent lexer doesn't use Lex"   * Fewer dependencies   * Could possibly allow for "fuzzier" parsing - since I'm just developing a beautifier, the parser wouldn't need to be nearly as strict or detailed as one for a compiler    * Parallelization - flex and bison (or what I've seen of them) use global state. If I want to parse multiple files at once (in separate threads), a custom solution would be simpler to compartmentalize


Established coding standards for pl/pgsql code

I need to standardize coding practices for project that compromises, among others, of pl/pgsql database, that has some amount of nontrivial code. I look for:   * Code formatting guidelines, especially inside procedures.    * Guidelines on what constructs are considered unsafe (if any)    * Naming conventions.    * Code documentation conventions (if this is practiced)  Any hints to documents that define good practices in pl/pgsql code? If not I'm looking for hints to practices that you consider good. There is related question regarding TSQL: Can anyone recommend coding standards for TSQL?, which is relevant to psql as well, but I need more information on stored procedures. Other related questions:   * http://stackoverflow.com/questions/1070275/what-indenting-style-do-you-use-in-sql-server-stored-procedures


using this in a constructor, why does it work?

I got two classes.   * busiObj(created from ancient flat files)   * key(provides means to tell busiObjs apart) key has a c'tor that takes a busiObj               public key(busiObj foo)     {         bar = foo.someThing;         [...]     }      I want to create the key in the c'tor of the busiObj               public busiObj(...)     {         myKey = new key(this);         [...]     }      However: Why on earth does it work?   I firmly expected the compiler to throw something like:   "You cannot reference an object that is currently being made, duh". So: How is it that I can reference an object while it is still being constructed?


User directory - framework

I'ld like to create a very basic directory where user can enter their social network profiles and pick a username. From that data a little website gets generated. The sign in process should be managed via Twitter or Facebook. Where do I start with this? Are there any frameworks, api's or something like that available? Thanks, Bob


Google App Engine: How to be notified when APIs change or become available?

I am thinking about writing a GAE app but am a little hesitant because the EULA gives Google full rights to change their APIs anytime they want, for any reason. Obviously, they'd be out of business quick if they just 'upped and refactored their entire APIs, so I have to imagine they have some kind of notification system, perhaps even an RSS feed, etc. to notify developers well in advance of looming changes, or new features coming out in future releases. However, for the life of me I can't seem to find any trace of the existence of such a notification system. Perhaps the Google forums is the only place to get such updates? I guess I'm asking any battle-worn GAE veterans for re-assurance that there are reliable ways of getting notifications about policy or API changes from Google such that I could react and make the necessary app changes without production breaking or impacting any clients.


Facebook Java API

I'd like to write a program in java (not a servlet, not jsp, not a webapp) which allows me to do simple things, such as connecting to a FB account and retrieve the status or posts on the wall. I know facebook no longer supports official JavaAPI, so I was wondering what are the best (and most simple, being the program very basic) unofficial api out there. If possible, i would also like some example-code. searching through the web, I've read that you need two secret keys to create a facebook application, and I have not a fb account. Is it indispensable to have an account? thank you everyone


I don't want to patent my business software, but I don't want to get ripped off later

I feel patents are innovation killers, but I don't want something I've written and put a private licence on end up being patented 3 years later by some troll. What's a good compromise here? Or, am I actually not at risk? _I understand most of the members on the site aren't lawyers._


ISO, Six Sigma, SEI-CMM, etc., in Fortune 500 companies

Do large corporations and product companies follow any standard quality models/processes at all?   For example, I have seen that many large organizations have proprietary processes in IT and software development. Back in the days (even before Motorola's Iridium project,) I remember many IT companies scampering for SEI- CMM certification. Do any of the Fortune 500 company try to adopt these quality processes? In my limited experience I have not seen them undergoing audits for adherence to processes. Most of the audits are either financial, or issues pertaining to legalities. Am I just being ignorant, or is this true? If true, how stringently do the companies adhere to the processes?


Long Keywords like `function` and `namespace`

In many English-based programming languages like C++ and JavaScript, there exist long keywords like `function`, `namespace`, `exception` (in OCaml languages) and such. Do you think shorter keywords like `func` should replace them? Why or why not? What about replacing them with digraph operators? The long keywords we will be mainly talking about, but not limited to, are mainly from curly-brace imperative languages: `function`, `namespace`, `implements`, `instanceof` and `synchronized` (I always misspell that). You should also show the examples from your favourite programming language.


A question regarding linked list vs vector insert/remove results comparison

I was reading this blog post: http://kjellkod.wordpress.com/2012/02/25/why- you-should-never-ever-ever-use-linked-list-in-your-code-again/ and I found there a code to run: http://ideone.com/62Emz I've compiled it using gcc 4.7.2 with `g++ -std=c++11` on my old laptop with T5450 cpu with two cores with 32 Kbytes L1 cache each and 2 Megabytes of (common?) L2 cache and I have got this results:               ********** Times in microseconds**********     Elements ADD (List, Vector)     ERASE(List, Vector)     100,     , 0, 0,                0, 0     200,     , 0, 0,                15625, 0     500,     , 0, 0,                0, 0     1000,    , 15625, 0,            0, 15625     4000,    , 109375, 140625,              46875, 31250     10000,   , 750000, 875000,              312500, 187500     20000,   , 2968750, 3468750,            1296875, 781250     40000,   , 12000000, 13843750,          5359375, 3156250     Exiting test,. the whole measuring took 45375 milliseconds (45seconds or 0 minut     es)      Which actually says an opposite, at least for `ADD` operation comparing to what author of that blog post says. List is faster for `ADD` than Vector. What conclusions should I make from my results? Does it proof anything? What should I think or understand?


Detecting misusage of delete[] vs. delete at compile time

I'd like to know if it's possible to detect the `delete` error commented below at compile time? Especially, I'd like to hear about g++ compiler.               ClassTypeA *abc_ptr = new ClassTypeA[100];       abc_ptr[10].data_ = 1;       delete abc_ptr; // error, should be delete []        Thanks in advance!


Acceptance tests done first...how can this be accomplished?

The basic gist of most Agile methods is that a feature is not "done" until it's been developed, tested, and in many cases released. This is supposed to happen in quick turnaround chunks of time such as "Sprints" in the Scrum process. A common part of Agile is also TDD, which states that tests are done first. My team works on a GUI program that does a lot of specific drawing and such. In order to provide tests, the testing team needs to be able to work with something that at least attempts to perform the things they are trying to test. We've found no way around this problem. I can very much see where they are coming from because if I was trying to write software that targeted some basically mysterious interface I'd have a very hard time. Although we have behavior fairly well specified, the exact process of interacting with various UI elements when it comes to automation seems to be too unique to a feature to allow testers to write automated scripts to drive something that does not exist. Even if we could, a lot of things end up turning up later as having been missing from the specification. One thing we considered doing was having the testers write test "scripts" that are more like a set of steps that must be performed, as described from a use- case perspective, so that they can be "automated" by a human being. This can then be performed by the developer(s) writing the feature and/or verified by someone else. When the testers later get an opportunity they automate the "script" for regression purposes mainly. This didn't end up catching on in the team though. The testing part of the team is actually falling behind us by quite a margin. This is one reason why the apparently extra time of developing a "script" for a human being to perform just did not happen....they're under a crunch to keep up with us developers. If we waited for them, we'd get nothing done. It's not their fault really, they're a bottle neck but they're doing what they should be and working as fast as possible. The process itself seems to be set up against them. Very often we end up having to go back a month or more in what we've done to fix bugs that the testers have finally gotten to checking. It's an ugly truth that I'd like to do something about. So what do other teams do to solve this fail cascade? How can we get testers ahead of us and how can we make it so that there's actually time for them to write tests for the features we do in a sprint without making us sit and twiddle our thumbs in the meantime? As it's currently going, in order to get a feature "done", using agile definitions, would be to have developers work for 1 week, then testers work the second week, and developers hopefully being able to fix all the bugs they come up with in the last couple days. That's just not going to happen, even if I agreed it was a reasonable solution. I need better ideas...


Branching library behavior based on 3rd party library existence

Someone proposed to me this pattern which I have never heard of before and can't find any information on it. The basic idea is, when building a library for other developers to use; if the developer includes my library along with a 3rd party library the behavior of the API calls to my library changes. An example:   1. I have a library/API for inserting, getting, updating, deleting on a database.   2. Developer includes a 3rd party database encryption library.   3. My library/API changes to require a "unencrypt(password)" call to be made before inserting, getting, updating, deleting. Is this a safe practice? Is there anything else out there like it? What advantages and disadvantages are there to this pattern?


Should you answer programming interview questions with library?

Some questions can be answered easily by using specific language library. For example Java has Set, Maps, and List. Is it possible to answer those coding questions during interview by using these library or should we go more with a traditional down to earth approach, making it a C- kind of answer?


Does long term programming affect writing in a native spoken languages?

So, I am getting some years under my belt in long term programming. I have noticed, however, when the frequency and duration started increasing in my coding sessions that when I actually went to write a paper, email, document, or anything else that required writing more than a few sentences that my writing quallity appeared to suffer. I started forgetting the basic rules and vocabulary of written English. I am now going back for my Masters and find that writing papers does not come as easy as it used to. I remember thinking to myself how my Creative Writing class back in my freshman year of college helped a great deal in writing for my other classes. Hate to say it, but it feels like I could use a refresher. Also, my hand writing has especially not got any better! I feel inclined to say it's a side-effect of long term programming but want know any if real studies have been done or just from personal experience from programmers.


How to store personal information properly?

It's not about security or something. There is a table to record user information, like username, password, postcode and so on, one record per person. There is also a table called post to record the posts the users posted. It's very easy to set a relation to identify the user who posted the post. But think of this situation, how to store the posts that has been read by a user? If use many-to-many relation, the table will increase to very huge size. What's more, there's a lot things to record, I just take one of them for example. I call this personal information. The problem is how should I store it properly?


What kind of research study would cause you to change your software practices?

Software development today isn't evidence-based. That is, we don't really choose technologies and practices based on the outcome of research studies the way (we hope!) they do in, say, medicine. As an example, there was a study published in early 2011 in the Journal of the American Medical Association that suggested removing lymph nodes of breast cancer patients does not improve survival rates, which had an immediate impact on surgical practice. Imagine you found yourself reading a paper about a software engineering study which suggested that a software practice or technology that you currently use did not actually have the benefit you thought it did: i.e., this study was in contradiction with your personal experience. Assuming that the paper was published in a reputable venue that you trusted, what properties would the study need to have for you to actually change your practices based on the result?


Time complexity of a nested loop where the inner value is decreased in every step

I have problems to give the right time complexity in O notation for the following loop:               k := 0     for i := 0 to N        for j := k to M          // something        k = k + 1      Where N = M. Without the modified starting value of j of the inner value this would be of course O(N * M), but with the decreasing running time of the inner loop in every step of the outer loop I am quite confused. How can this be approached?


IRC Bot permission structure, best approach?

I'm making an IRC bot in PHP. And I've come to the point when I need to determine how would user permissions/accesses would look in the database (and in the application in general). Here are the requirements:   * There are global and local permissions, global are for all channels, while local are channel specfiic.   * There are permissions such as "root", "bot_admin" "glob_op" "op on #channel", in this example, each is weaker than the last (root is strongest, meaning that no one can take actions against root).   * I haven't completely decided on exactly how many permissions are there, and the bot will be extensible, so there needs to be an option of expanding. Some approaches I had in mind:   * Assign each permission level a number (1, 2, 4, 8, 16) and add them together to form the access level of a specific user (even adding all of the numbers until `n-1`, they would still be lower than `n`). As for expanding, I could leave gaps (1, 16, 256, etc) and fill it in later. I don't think it's a very good one, as it would be hard to maintain and read later on, even if I use constants to make it more readable.   * Have each permission in its own boolean column. That seems just silly, and there's no easy way of determining the power relations between each role. So what say you? Have a better approach I can take?


Is "regular" a technical term for a grammar?

Reading the Go language specs, I read in the intro: "The grammar is compact and regular, allowing for easy analysis by automatic tools such as integrated development environments." Is the word "regular" here a technical term, or should it be interpreted just as a vague English word?


What quality level in the commit history can/should I expect/enforce?

I worked as a lone developer for a long time. During this time, I developed a way of formulating and ordering commit messages: Refactor first, describe exactly the reason for the commit in the message, link to the issue tracker, ... There is even a script to create several sorts of change log (public, company-internal, developer) from the commit history. This way I always know, when and why the code in the codebase changed to the state it is now. With the advent of interactive rebase and commit reordering, I can easily make sure that history (and, thus, documentation) looks exactly the way I want it to be. Bad code doesn't even get into the history. So, every commit has its well-defined purpose. It took me years to evolve this practice, which I consider a good one. (Is it?) However, applying this to someone else's code changes (i.e., rewriting the history of someone else's changes) is, for me, a painfully time-consuming task. I have tried this in order to identify unnecessary or even faulty changes. The total size of the patch in question is slightly too big to be reviewed as a single unit, and there are a few questionable code changes. In fact, it turns out that I cannot afford to control the code base as a "dictator". It just costs too much time. So I'd like to lose some control while maintaining a good quality of the code. Currently, I just don't see how to achieve this. "How clean" should the history of a project be? Which format and granularity for the commits should I require? Should I ask the developer to reformat history (e.g., to split a commit), even if it would require education on how to split a commit after the fact? Should I teach developers to work on feature branches? Can commit templates help? How frequently should the changes by the others be reviewed?


What is a software maintenance retainer contract?

I'm a one man software start up and need to consider a software maintenance retainer contract for a client. What is this, in simple terms? How could it benefit me or my client?


The false element in a Logical operation

I wish to know if there's some way to know which is the elemnet of a logic operation is false?   Example.               if( String.IsNullOrEmpty(obj1) || (String.IsNullOrEmpty(obj2) )        throw("...............");       How can I kown which one of those is the empty one?


How do I get away from PHP in the web industry?

I'm just looking for some tips on getting away from using PHP for web development. I'm self-employed but it seems like all of the work I find deals with PHP. I'm not complaining about the work -- just the poor choice of a language that is incredibly popular. I'd love to do my web development in Python, Perl, C#, or even a fun and fancy functional language. There's the old saying that you don't tell a carpenter what kind of a hammer to use. At the same time, you do tell them what kind of material to build your house out of and how much you're willing to spend. The problem I am running in to is that I don't know how to get out of this spiral. I can't just turn down work because then I wouldn't have any. I really don't want to go work for another company -- and even if I did, I'd probably still be stuck using something I don't enjoy. I'm hoping someone has "been there" before and might have some good ideas on how to get out of this situation. Thanks!


calling test methods within other test methods

To test a method that returns a clone of the object it is called on, i need to re-run the test suite on the newly created object if i am to ensure that full functionality is retained, i found my instinct was to clone the object then call all other test methods in sequence i order to reduce code duplication. However that approach now smells to me and i can't pinpoint why. Is there a better way to test this kind of functionality?


Is there value denoting a key as "Primary"?

Question: Is there value in denoting a key as "Primary"? This question is not about the definition of a primary key. It is not about the fact primary's aren't nullable. It is not about implementations such as MySQL which automatically perform clustered index voodoo behind the scenes on primary keys. **NOTE** : The question is not about the benefits of auto-number-ID surrogates over natural keys. Suppose a table has 3 candidate keys. All non-nullable. All immutable. I find no value denoting a key as "secondary" or "tertiary". I don't find the concept of precedence useful when dealing with multiple keys. I find the same logic against "secondary" and "tertiary" flags applies to the "primary" flag. I even feel the word "candidate" is not useful for a key. It implies the candidate is not as important as the key that won the primary election. I don't feel precedence has any place in describing keys. The attributes of the key itself (unique, non-nullable, etc) should be sufficient. Would the relational model be missing anything if we did not have the "primary" attribute to describe 1 of a table's keys?


What does the term Virtualization encompass?

I have seen on a number of resumes the term "virtualization." While every resume is unique, what does the broader term or skill of "virtualization" mean or imply? I feel that the ability to install virtual machines is not the only thing that this means. I have installed VMs and in my experience it was mostly following instructions. Is there something else to it that I'm missing, like actually _programming_ virtual machines? Is there an implied IT expertise on the issue, or relevant programming knowledge?


How would you explain HTTP to a lay person

I got this question in one of the interviews I took. I started by explaining that it is like a set of rules that should be followed while moving resources around, but I did not feel convinced. Is there any other analogy or take on this question ?


Does contributing to open source projects to boost a résumé make sense?

I've only worked on commercial projects, and I'm having a hard time trying to find a project that interests me. I'm looking at a new job soon, and I'm thinking about contributing to a few open source projects in the short term so that I can add them to my résumé. Is having open source projects on a résumé important? If so, would trying to contribute to several in a few months look too much like trying to boost my résumé?


How safe are hidden AJAX requests that fake performance?

## What is a hidden AJAX request? I've noticed an increase in the usage of hidden AJAX requests designed to make a user's action appear to happen immediately. I'll refer to this type of AJAX request as non-blocking. It's an AJAX request made without the user being aware it's happening, it's performed in the background and it's operation is silent ( _there is no verbose to indicate a successful completion of the AJAX call_ ). The goal is to make the operation appear that it has happen immediately when it really has not finished. Here are examples of non-blocking AJAX request;   * User clicks delete on a collection of emails. The items disappear immediately from their inbox, and they can continue with other operations. Meanwhile, an AJAX request is processing the deletion of the items in the background.   * User fills out a form for new records. Clicks save. The new item appears in the list immediately. The user can continue to add new records. To clarify, here are examples of blocking AJAX request;   * User clicks delete on a collection of emails. An hourglass cursor appears. The AJAX request is made, and when it responds the hourglass cursor is turned off. The user has to wait a second for the operation to complete.   * User fills out a form for new records. Clicks save. The form turns grey with an AJAX loader animating. A message is shown "Your data was saved", and the new record appears in the list. The difference between the two above scenarios is that a non-blocking AJAX setup does not provide feedback of an operating performing, and a blocking AJAX setup does. ## The Risk Of Hidden AJAX Requests The biggest risk of this style of AJAX request is that the web application could be in a completely different state when the AJAX request fails. For example, a non-blocking example;   * User selects a bunch of emails. Clicks the delete button. The operation appears to happen immediately (the items just disappear from the list). The user then clicks the compose button and starts typing a new email. It's at this time that the JavaScript code discovers the AJAX request failed. The script could show an error message, but it really is pointless at this time. Alternately, a blocking example;   * User selects a bunch of emails. Clicks the delete button. Sees an hour glass, but the operation fails. They get an error message saying "error. blah blah blah". They are returned back to the list of emails, and they still have the emails they wanted to delete selected. They could attempt to delete them again. There are also other technical risks for performing non-blocking AJAX requests. The user could close the browser, could navigate to another website and they could navigate to another location in the current web that makes the context of any error response meaningless. ## So Why Is It Becoming So Popular? Facebook, Google, Microsoft, etc.. etc.. all these large domains are increasingly using non-blocking AJAX requests to make operations _appear_ that they are performed instantly. I've also seen an increase in form editors that have _no save or submit button_. As soon as you leave a field or press enter. The value is saved. There is no _your profile has been updated_ message or saving step. AJAX requests are not a certainty, and shouldn't be treated as successful until they have completed, but so many major web applications are operating just like that. Are these websites that use non-blocking AJAX calls to simulate responsive applications taking an unnecessary risk at the cost of appearing fast? Is this a design pattern that we should all be following in order to remain competitive?


Performance of a Skip-List algorithm

Here is a simple code for a randomized skip-list:               Coin_Side flip()     {         if ( random() % 2 == 0 )             return HEADS;         else             return TAILS;     }      Note: random() returns an integer that uses a modulus of the form M = 2^B. Then, what is the expected performance of the skip list algorithm? So we have: (ax mod M) mod 2 = (ax mod 2^B) mod 2 = (ax mod 2) mod 2^B I can see than ((ax mod 2) == 0) will be true if ax is even. Then, by adding mod 2^B, we will skip more values in the skip-list. We would have only the even numbers that are multiples of 2^B. So would that make the algorithm better or worse?


Why doesn't libxml2 support XPath 2.0?

Libxml2 is the faster, stable and most popular "open DOM engine"... And the "XML C parser and toolkit of Gnome". The initial release of Libxml2 was September 1999, 13 years ago. XPath v1.0 was also released at 1999. XPath v2.0 became a recommendation on January 2007, 6 years ago. We can suppose that the Libxml2 community have time and people to develop a XPath2... So, _what is the problem?_ **Why doesn't libxml2 (or a "libxml2 fork" or an "experimental lib"!) support XPath 2.0?** Some raised hypotheses to discussion at answers,   1. Because Libxml2 community (and Gnome community) dislikes and have no motivation to develop something to XPath2 or xQuery.  1.1. XPath2 needs (by mathematical proof) a very heavy parser, much slower, etc. that is not suitable to real-world Libxml2 applications. 1.2. Other "ideologic" dislikes/motivations.   2. Because it is written with C, and for XPath2 is better to develop with C++.   3. Because the above hypothesis of "Libxml2 community have time and people" is false.   4. Because XPath2 became stable in 2010 with its "Second Edition" release, and ~2.5 years is not (?) enough time.


how to work in team and organize tasks in web development

My problem is that i used to work as a freelancer web developer. Now i work in a company and have a small team. I'm responsible for organizing this team to work in a project. I have no idea about organizing tasks or putting plan for a team. Can any one tell me how to do that.


How to ensure the success of processes after a deadlock exception occurs?

No matter the programming language is and whatever the database is, the concept should be the same: I have 2 threads, each locking some database entities and inserting new data in database.   Let's suppose the fact that those threads run simultanously may cause deadlock exceptions. Obviously, the main action we can do first of all is to analyse the code deeply to find a good alternative avoiding any deadlocks.   But sometimes, we really can't avoid them. Should I catch the exception and retry the concerned process?   At first glance, it would be acceptable, but...what if those conflicting processes are replayed at the same time, other deadlocks again (the snake biting its tail)? What is a good way to ensure that the processes eventually succeed?


Term to describe keyword followed by statement block

Is there a general term to describe a keyword followed by a statement block? E.G.               if() {statement block}     while() {statement block}     try{statement block}     finally{statement block}      Or even something made up: `controlScope{statement block}`