Parsing Razor-style Templates

I want to build a template engine (ITT not another template engine...) based on Razor. I've been at it for quite a long time not getting anywhere and quite frankly I'm at my limit. I've tried rolling my own, I've tried generating using ANTLR and I reckon I just need someone to tell me if I have to bite the bullet and do this the hard way. To be honest I've been trying to do this as simple as possible. '@' denotes the start of a special statement. A statement could be:   * an identifier of a variable   * an identifier of a function call. Parens must be balanced, and handle strings.   * the start of one of Java's logic constructs (if, for, while/do)   * a single line statement that yields a output value @( )   * a multi line block of statements @{ } The part which is killing me: everything within {} is treated as code UNLESS:   * it is escaped with @:. The line is treated as text   * a html tag is found . Everything from that point on is treated as text So, now we have issues as the '<' token now has context. It could either LT or the start of a HTML tag. It does not help either that a tag could also have attributes, and each attribute could also have special statements in them. Then, I also need to balance brackets and string quotes as well. There is also the added complexity of the lack of terminating sentinels (unlike say, php, which has tags). It seems impossible to parse these as alternating CODE - RAW - CODE - RAW tokens, so that the end result is simply me combining pieces of tokens into a Java class and let the Java compiler handle syntax. I'm just about to double down and reimplement the Java grammar and parse everything. Something which I am not keen on doing... :( Anyway, let me know if there's any easier ways to approach this, or how you would attempt this exercise. Regards, Daryl


Are there any surveys on to what degree developers like or hate scrum?

Background: During a conference an analyst pointed out in a tweet that developers hate scrum. Myself and another person responded that this was not the case, and started discussing different scenarios on why developers would dislike scrum. One of the scenarios where that lazy developers are not able to hide in a scrum project. They are constantly challenged by the team to contribute. This discussion resulted in a blog post and video http://elsewhat.com/2010/05/20/lazy-developers-hate-agile-and%C2%A0scrum/ I've gotten three comments which I've tried to answer in a neutral way, but they comments do point out that there are some people who loathe scrum (and I am always 100% certain they are not lazy developers). **Question** **Have there ever been a survey among developers on to what degree developers like or hate scrum ?**


iOS chat application design, sending/relaying the message over to the end user

I have a design question. Let us say you were tasked with building a chat application, specifically for iOS (iOS Chat Application). For simplicity let us say you can only chat with one person at a time (no group chat functionality). How then can you achieve sending a message directly to an end user from phone A to phone B? Obviously there is a web service layer with some API calls. One of the API calls available will be `startChat()`. After starting a chat, when you send a message, you make another async call, let us call it `sendMessage()` and pass in a string with your message. Once it goes to the web service layer, the message gets stored in a database. Here is where I am currently stuck. After the message gets sent to the web service layer, how do we then achieve sending/relaying the message over to the end user? Should the web server send out a message to the end user and notify them, or should each client call a `receiveMessage()` method periodically, and if the server side has some info for them it can then respond with that info? Finally, how can we handle the case in which the user you are trying to send a message to is offline? How can we make sure the end user gets the packet when he moves back to an area with signal?


When is a Use Case layer needed?

In his blog post The Clean Architecture Uncle Bob suggests a 4-layer architecture. I understand the separation between business rules, interfaces and infrastructure, but I wonder if/when it's necessary to have separate layers for domain objects and use cases. What added value will it bring, compared to just having the uses cases as "domain services" in the domain layer? The only useful info I've found on the web about a use case layer is an article by Martin Fowler, who seems to contradict Uncle Bob about its necessity: > At some point I may run into the problems, and then I'll make a Use Case > Controller - but only then. And even when I do that I rarely consider the > Use Case Controllers to occupy a separate layer in the system architecture. Edit: I stumbled upon a video of Uncle Bob's Architecture: The Lost Years keynote, in which he explains this architecture in depth. Very informative.


Why is there no Git client for Android?

Since there is a pure Java implementation of basic Git features called JGit, which also has a couple of heavy-duty users (Gerrit), I can't help to wonder: why hasn't someone implemented a basic Git client for Android yet? Anyone know any reason which would make this impossible (apart from time)?


Should we adopt an agile methodology when rewriting an existing application from scratch?

I work for a small product based company. We are about to re-write our existing product from scratch. We are planing to adopt Agile methodology for our development. Now my question is as we have all the requirements even before start of project (as we are re-writing the existing product), is it worth to dive into Agile world? Isn't agile more useful when you don't have all the requirement upfront and you get your requirement in phases? Secondly, let's say if we jump into Agile, whats the best practice to design database? Let's say in our first iteration we just create a login system (user can login, logout etc). Do we just need to create Users table without worrying about other tables? And other tables would be evolved as our product would progress?


How do I find a qualified web designer in my area?

I just sent out emails to five local web design companies to my area asking to take drawings to HTML/CSS/jQuery. None of the ones who accepted the deal seem suitable to myself. Others rejected the offer because they wanted to 'provide an end-to-end solution' or are 'booked till June'. The local companies did not seem suitable to myself because my review process is this: goto their website, do a view-source. I'll see really weird things (contact us forms that go nowhere), really old things (mm_menu.js), and portfolios that are non-existent (aren't on the site, don't link anywhere, or otherwise). The company would like to hire as locally as they can rather than out-source to another country. **Answers I'm looking for**   * Processes you use when searching for someone   * How you qualify their aptitude for the project   * Anything that you think I'm doing wrong, or should be doing also. **Answers I'm not looking for:**   1. "Hello sir please contact me we do everything for 10 dolla."   2. My bud's great at this stuff, call him.   3. example.com is the best for this.


Is mootools alternative of jquery + backbone / spine / sprouteCore

I was a full time java developer, now I'm also working with JavaScript and Android. A couple of years back when I started learning JavaScript, the first library I tried was jQuery. But it made my life harder, and after sometime I started writing fairly large a JavaScript app. It wasn't coming together for me using jQuery. I had huge a code base without much of a structure. Method blocks updating HTML blocks using selectors. Then I tried MooTools and obviously as a Java developer it appealed to me a lot. And I was able to write managable web apps having huge code base. As per my understanding MooTools is not considered a preferred way to write JavaScript because it mimics conventional OO over default prototype-based OO language. So now to really understand Javascript and desire of walking with the world, I decided to try other approaches, so again I turned back to jQuery, and realise that only jQueryis not enough. So started looking at current trending frameworks like backbone, spine, ember.js, sprouteCore. Strangely I found that these frameworks mimic conventional OO like MooTools only by having constructors and creating a object of class and reusing this class object to create instance objects. So   * Am I missing something?    * Is MooTools really wrong?    * MooTools project is very alive and releases new versions/features, but I don't see many people talking about it on internet, also there are no comparisons vs backbone/spine etc.


Preparing for an interview slightly outside my skillset

I have 4 years of experience in web development, so: PHP, javascript, Mysql, HTML, CSS, the usuals. I have an interview soon for a position involving c#, wpf and other desktop programming languages. Its a junior position, which I perceive as: someone willing to learn, junior to no knowledge and fast learner. I have very limited experience in c# and wpf but no knowledge of some other requirements. In the initial round of interviews which were conducted via video, so not face to face, I was honest, I told them I am keen to learn, but have limited and no experience in what they offer but I do have transferable skills. Surprisingly to me they offered a face to face interview considering how honest I was about I didn't atm meet much of the desired requirements. What would have lead them to offer me a face to face interview? How should I approach this interview without sounding to repetitive and begging whilst being honest but confident?


Is a development environment required for small projects?

I won a bid on Elance and was had a request to fix some css and html issues with a WordPress site. How do I make changes to the document without working on the live site? Do you set up a development environment for every job you get? This would be time consuming on a job that pays very little. I was offered access to the wp-admin and the cpanel but any changes would affect the live site immediately. What is the best practice for changing and updating sites for clients? Any advice on how to develop on a site that you do not have the full install on is helpful.


Recruiting programmers- going beyong the code

I'm recruiting coders. The first step is to carry out a test to cut out the "chafe", but do I just make a decision based on the fact that the shortlisted candidates are the best in the world at coding? What should I look out for that would guarantee that the persons i finally hire are not only the best coders but also are the best fit for my company. What should the tests exactly measure?


Technical reasons to prefer coding business logic to support Unicode (when not required)

I have a legacy application in which the UI and business logic are already reasonably well-separated. There is a proposal to separate them even further, turning the core application into a "service" (without UI) and writing a kind of "UI Server" as part of it to which various UIs (potentially in various languages, and for various different devices and operators) can connect to get/set the data to drive the application via those UIs. On the surface, this seems to make a nice separation between the business logic, which is currently completely ignorant of the possibility of Unicode, and the UI, which is going to need to get very familiar with Unicode to support multiple languages in the UI(s). Now this application essentially monitors a production process, and has very little (if any) traffic directly from UI to database via the business layer. It strikes me that the "natural language" of this process might as well be Chemistry or Mathematics, and so internally I should stick to the language that best describes it, so long as I can translate from that language into anything any UI requires (which I believe should be possible). This leads me to prefer (the simplicity and familiarity and least work path of) retaining old-fashioned 8-bit chars over moving to Unicode. Are there any technical reasons to reject keeping the business logic part of an application ignorant of Unicode like this? And even if the "natural language" of the system were "English-without-too-many-strings-or-dates" rather than Chemistry, would that make a difference?


How common is prototyping as the first stage of development?

I've been taking some software design courses in the past few semesters, and while I see the benefit in a lot of the formalism, I feel like it doesn't tell me anything about the program itself:   * You can't tell how the program is going to operate from the Use Case spec, even though it discusses what the program can do.   * You can't tell anything about the user experience from the requirements document, even though it can include quality requirements.   * Sequence diagrams are a good description of how the software works as the call stack, but are very limited, and give a highly partial view of the overall system.   * Class diagrams are great for describing how the system is built, but are utterly useless in helping you figure out what the software needs to be.  Where in all this formalism is the bottom line: how the program looks, operates, and what experience it gives? Doesn't it make more sense to design off of that? Isn't it better to figure out how the program should work via a prototype and strive to implement it for real? I know that I'm probably suffering from being taught engineering by theoreticians, but I need to ask, do they do this in the industry? How do people figure out what the program actually is, not what it should conform to? Do people prototype a lot, or do they mostly use the formal tools like UML and I just didn't get the hang of using them yet?


Is there a way to write this fold neater in Haskell?

I have the following small function that uses foldr to find the largest second number of a 2-tuple:               listMax :: [(Int,Int)] -> Int     listMax = snd . foldr (\(_,freq1) (_,freq2) -> (0,max freq1 freq2)) (0,0)      My question pertains to the body of the lambda:               (0,max freq1 freq2)      I had to make it into a tuple with a dummy head so that it matches it's own input for the fold. To me though, it looks ugly and makes it harder to read. Is this the standard way of dealing with this situation, or is there a idiomatic way around this?


Is it legitimate to ask co-workers to use specific browser in an intranet website?

I developed an intranet (local network) `ASP.NET` web project for my co- workers. In the development process I used `Chrome` and `Firefox` and didn't test much with `Internet Explorer`. The website works well with `Firefox` and `Chrome` and with `IE` it had major bugs. **Is it legitimate to ask the users to use`Chrome` or `Firefox`?** They are all co-workers (around 15 users). I don't want to spend time fixing the bugs for `IE`, some might be related to stuff I can't fix myself (`jQuery` things), if I wanted to be compatible with all browsers, I would have to make a major re-design,


When should I care about performance?

For the longest time in places like Java's IRC channel, SO, and other places I've been told something along the lines of "Worry about how the code looks and its readability/understandability now, and performance later if absolutely necessary". So for the longest time, I haven't really been OCD about performance for my small desktop or web apps, just removing the obviously inefficient. Most responses are "What about scalability?". Thats a legitimate point, but if my app was only built to parse, say, files 10,000 lines long, should I make my code a mess for the small percentage of people that are going to shove in a 1,000,000 line file? My main question is when should I trade the easy but somewhat inefficient ways of doing tasks for big giant complicated beasts that do things extremely quickly but destroy any possible ways of upgrading and make the code excessively difficult and prone to rewriting anyway by the next developer?


Changing method signature for implementing classes in PHP

Is there any decent work around to PHP's lack of Generics that allow static code inspection to detect type consistency? I have an abstract class, that I want to sub-class and also enforce that one of the methods changes from taking a parameter of one type, to taking a parameter which is a sub-class of that parameter.               abstract class AbstractProcessor {         abstract function processItem(Item $item);     }          class WoodProcessor extends AbstractProcessor {         function processItem(WoodItem $item){}     }      This is not allowed in PHP because it's changing the methods signature which is not allowed. With Java style generics you could do something like:               abstract class AbstractProcessor<T> {         abstract function processItem(T $item);     }          class WoodProcessor extends AbstractProcessor<WoodItem> {         function processItem(WoodItem $item);     }      But obviously PHP doesn't support those. Google for this problem, people suggest using instanceof to check errors at run-time e.g.               class WoodProcessor extends AbstractProcessor {         function processItem(Item $item){             if (!($item instanceof WoodItem)) {                 throw new \InvalidArgumentException("item of class ".get_class($item)." is not a WoodItem");             }          }     }      But that only works at runtime, it doesn't allow you to inspect your code for errors using static analysis - so is there any sensible way of handling this in PHP? A more complete example of the problem is:               class StoneItem extends Item{}     class WoodItem extends Item{}          class WoodProcessedItem extends ProcessedItem {         function __construct(WoodItem $woodItem){}     }          class StoneProcessedItem extends ProcessedItem{         function __construct(StoneItem $stoneItem){}     }          abstract class AbstractProcessor {              /**          * @return ProcessedItem          */         abstract function processItem(Item $item);              function processAndBoxItem(Box $box, Item $item) {            $processedItem = $this->processItem($item);            $box->insertItem($item);         }              //Lots of other functions that can call processItem     }               class WoodProcessor extends AbstractProcessor {         function processItem(Item $item) {             return new ProcessedWoodItem($item); //This has an inspection error         }     }          class StoneProcessor extends AbstractProcessor {         function processItem(Item $item) {             return new ProcessedStoneItem($item);//This has an inspection error         }     }      Because I'm passing in just an `Item` to `new ProcessedWoodItem($item)` and it expects a WoodItem as the parameter, the code inspection suggests there is an error.


Am I slow or is this normal?

I am currently in high school and I discovered programming 3 years ago but I am still not "good" and it is difficult for me some times to understand, especially about data structures, bytes etc... Moreover, when I program I waste most of my time not creating but searching my syntax error, commas and all those things. I am very slow. I would love to be an expert is programming but I feel like I am too "dumb" to go threw those difficulties. At the same time, I feel passionated about Technology, Computers and Coding... So, is it normal to be slow as I am even 3 years after discovering development or Am I just not made for this? Does anybody experienced the same feelings? Would it become better with college?


How to work on my personal ideas during the weekend?

I'm working full time 5 days a week, mostly between 10 and 14 hours a day. In the end of the day I'm very tired and just wanna take a shower, hang out and go to sleep. I have a lot of ideas that I want to implement and someday sell maybe through an online software business. I have my weekends free. However, when I get to the weekend I can't even imagine myself turn on the computer. But I really want to make my ideas happen, and I can't leave my job right now to devote myself only to my ideas. What do you say? Do you find some method helpful? Do you use some technique? Thanks


Prevalence of "back end" programmer roles in ASP.NET (MVC) projects?

First, unless anyone has better definitions, let's define "back end" and "front end" according to their usage here: Is it common to separate back-end and front-end into two positions on web development projects?. How common is it to find programmers exclusively assigned to back end or front end roles on a team? What's the scope of their responsibilities?


We are spending more time implementing functional test than implementing the system itself, is this normal?

Basically, we have three main projects, two of them are web services, and the other is a web application. While I'm satisfied with covering as much as we can of our web services with functional test (all three projects have their proper unit tests), functional tests for the web application are taking a lot of developer time to get implemented (and by a lot I mean two times, or some times more, the time that takes to implement the functionality being tested with unit test included) The manager policy is to test every single functionality we add, even if is not business critical (i.e a new C.R.U.D). I do agree with testing all of the web services functionality, because is hard to manually test them, and also, this tests run fast and doesn't take to much to implement. So, what's the value in spending more time writing functional test, than writing system code, unit test and fixing QA tikets? Is this normal? shouldn't we be writing functional test only for critical functionality and let QA to do regression tests over no critical functionality? Note: we are not developing medical software or NASA software or nothing that critical. Note2: sorry my bad English!


Apache License and patents

I am trying to understand how Apache License affects patents. In regards to the Apache website http://www.apache.org/licenses/LICENSE-2.0 section 3, am I right to say for the first part that it is saying the licensee is allowed to do pretty much anything with the patent? In the latter part, is it saying that if a licensor decides to sue someone who is infringing over their patent they will lose all their patents or is it talking about the licensee? I'm not a lawyer and this is all very confusing =(


Reasons for removal of function types in Java 8

I have been trying to understand why the JDK 8 Lambda Expert Group (EG) decided not to include a new function type into the Java programming language. Going over the mailing list I found a thread with the discussion about removal of function types. Many of the statements are ambiguous to me, maybe because of the lack of context and in some cases because of my limited knowledge on the implementation of type systems. However, there are a couple of questions that I believe I can safely formulate in this site to help me understand better what they meant. I know I could ask the questions in the mailing list, but the thread is old and all decisions are already made, so chances are that I will be ignored, above all seeing that these guys are already getting delayed with their plans. In his answer to support the removal of function types and endorse the use of SAM types, Brian Goetz says: > No reification. There was a long thread about how useful it would be for > function types to be reified. Without reification, function types are > hobbled. I couldn't find the thread he mentions. Now, I can understand that the introduction of a structural function type may imply certain complications in the Java mostly nominal type system, what I cannot understand is how parametrized SAM types are different in terms of reification. Aren't they both subject to the same reification problems? Does anyone understands how function types are different than parametrized SAM types in terms of reification? In another comment Goetz says: > There are two basic approaches to typing: nominal and structural. The > identity of a nominal is based on its name; the identity of a structural > type is based on what it is composed of (such as "tuple of int, int" or > "function from int to float".) Most languages pick mostly nominal or mostly > structural; there are not a lot of languages that successfully mix nominal > and structural typing except "around the edges." Java is almost entirely > nominal (with a few exceptions: arrays are a structural type, but at the > bottom there is always a nominal element type; generics have a mix of > nominal and structural too, and this is in fact part of the source of many > of people's complaints about generics.) Grafting a structural type system > (function types) onto Java's nominal type system means new complexity and > edge cases. Is the benefit of function types worth this? Those of you with experience in the implementation of type systems. Do you know any examples of these complexities or edge cases that he mentions here? Honestly I get confused by these allegations when I consider that a programming language like Scala, which is entirely based on the JVM, has support for structural types like functions and tuples, even with the reification problems of the underlying platform. Don't get me wrong, I am not saying that a function type should be better than the SAM types. I just want to understand why they took this decision.


Using xml datatype to store a "shopping cart"

For my final project in school we have to develop an online shop. This shop should have a cart where items can be placed whether or not you are logged in. If you log out the cart shouldn't empty and should still be shown. So my question is would it make sense to store the cart as xml in the database(ms sql server)? There is potentially a (relatively)fair amount of data that should be kept, is it possible that this could deliver any performance benefits or am I way off base?


The MsC gray zone: How to deal with the "too unexperienced on engineering/too under-qualified for research" situation?

Last year I've got a MsC degree on CS. On the beginning of the MsC course, I was keen on moving on with research and go for a PhD. However, as the months passed, I started to feel the urge to write software that people would, well, _actually use_. The programming bug had bitten me, again. So, I decided that before deciding on getting a PhD degree, I would spend some time on the "real world", working as a software developer. Sadly, most companies here in Brazil are "services" companies that seem to be stuck on the 80s when it comes to software development. I have to fend off pushy managers, less-than-competent coworkers and outrageous software requirements (why does everyone seem to need a 50k Oracle license and a behemoth Websphere AS for their CRUD applications?) on a daily basis, and even though I still love software development, the situation is starting to touch a nerve. And, mind you, I'm already lucky for getting a job at a place that isn't a plain software sweatshop. Sure, there are better places around here or I could always try my luck abroad, but then I hit the proverbial brick wall: > Sorry, you're too unexperienced as a developer and too under-qualified as a > researcher I've already heard this, and variations of, multiple times. Research position recruiters look for die-hard, publication-ridden, rockstar PhDs, while development position recruiters look for die-hard, experience-ridden, rockstar programmers. To most, my MsC degree seems like a minor bump on my CV (and an outright waste of time for some). Applying for abroad positions is even harder, since the employer would have to deal of the hassle of a VISA process, which I understand that, sometimes, is too much. Now I'm feeling I've reached a dead-end. I'm certain that development (and not research) is my thing, so should I just dismiss my MsC (or play it as a "trump card") and play the "big fish on a small pond" role while I gather some experience and contribute on some open-source projects as a plus? Is there a better way to handle this?


How important is understanding the coding behind sorts?

First off, if this is in the wrong place I apologise. I wasn't too sure on which of the Stack Exchange sites to ask it. I am studying Software Development at university, on a one year conversion course. My main programming language is Java. We have just finished studying searches and sorts. Focussing on the latter in particular, I had a hard time working through the intricacy of the code. Some, like an insertion sort, were obvious enough. Others, like the merge sort, I found extremely tricky to get my head around. I understand totally _how_ they work, I just wouldn't want to _implement_ my own. I've been told most programmers don't create their own sorts/searches as the built in methods in Java are more reliable and generally faster. However, it's considered good practice to know these sorts. When I look at a sort like the merge sort, or binary sort, I think to myself that I could never have come up with such solutions. They are too intricate and complicated. This brings me to my question. Do most programmers use sorts like people use simple Maths formulae, e.g. the area of a triangle or circle, where you apply it almost mesmerically? As a programmer would you put any real effort into trying to develop new, or more efficient sorts? Or if you knew a sort was needed would you simply know which was better through the bigOh notation and then just copy and paste the same thing in, without ever really thinking about the coding behind it? Note: if this question is not fit for Q&A (I did look at the FAQ and I think it is), please advise me where I could post. Thank you.


spotting graph cycles - simple explanation

could some please help me understand how to find cycles in graphs in laymans terms? I have read other questions, such as This one and also some of the wikipedia pages, but they seem to descend rather quickly into mathematical jargon. I have a model of the graph in java, modelling nodes, and 'in' and 'out' edges - and the model knows nodes only connected in one direction, this allows me to find the leaf nodes as a starting point, my plan was to walk back up the graph from each of these leaf nodes, for each "walk", keeping a list of all the other nodes I've found on my route. If I see something already in the list at any point, I'll know I've found a cycle in the graph. This however feels a little simplistic. I'm sure this is a solved problem, it would just be nice if it could be explained in simple terms. -ace


Does this kind of programming language exist?

I'm thinking about creating my own pet programming language, and I have been wondering if similar language already exists. The basic idea is that the language itself would be dynamically typed with strong metaprogramming capabilities (think Ruby). But instead of running it directly, it would be interpreted/expanded into another language, that would be statically typed, with static data structure and minimal dynamic dispatch (think C). This would then be compiled to machine code. The expansion could happen before running the program or during it's deployment, and all necessary libraries would be part of it, instead of each library being expanded separately. Before I start working on it, I would like to know if anything like that already exists. So I can either inspire myself or drop it, because it would be useless work.


How specific should be an interface about its implementation details?

Perhaps I should have picked a better title, but anyway... Basically what to do with two or more implementations that have the same public interface, but they are meant for slightly different purposes having a slightly different behavior? For example let's say a proxy class that uses the same public interface of the original class but with important changes in its behavior.               interface MyTest     {         getSomething() : MySomething;     }          interface MyTestImmutable (extends MyTest ?)     {         // same interface, but in this case the following method         // is supposed to return a clone of the stored MySomething instance         getSomething() : MySomething;     }      Thanks


Astronomy and Cosmology Computing?

I'm wondering if there is any course in University or anywhere else or probably company that has a department for Astronomy and Cosmology related computer science (I know NASA will need one). I would like to know how much demand or popularity of this field of programming. Where else will this field being used?


How do you avoid being a "blowhard"?

When I'm passionate about something (particularly programming) I find it really easy come off like the guy Peter G. was talking about in Dealing with the “programming blowhard”. So what techniques do you use to 1) Identify when you are indeed a blowhard? 2) Communicate something "important" without seeming self important? Specific example help like When giving criticism ask "have you considered what happens when XXX changes" instead of "never take dependencies on implementation details" When giving advice "showing with code is better than talking" or use a reference.


What security is used by default in WSHttpBinding (service side) or the WCF Test client (client side)?

I recently moved a service from BasicHttpBinding to WSHttpBinding (i.e. soap 1.1 -> soap 1.2). In WCF, using WSHttpBinding() makes it start using some default security settings. I presume the same default security settings are also used by the WCF Test Client since the client and server can continue talking after switching to the 'secured' WSHttpBinding. In fiddler, I've confirmed this security setup since I can witness a more complex security handshakes from the previously dead-simple request-response i.e. **Before:** (BasicHttpBinding)   1. [HttpRequest ] (Soap Request In Clear) [HttpResponse] (Soap Response In Clear) **After:** (WSHttpBinding)   1. [HttpRequest ] RequestSecurityToken [HttpResponse] RequestSecurityTokenResponse   2. [HttpRequest ] RequestSecurityToken [HttpResponse] RequestSecurityTokenResponse   3. [HttpRequest ] RequestSecurityTokenResponse  [HttpResponse] RequestSecurityTokenResponseCollection   4. [HttpRequest ] EncryptedData  [HttpResponse] EncryptedData   5. [HttpRequest ] EncryptedData **(actual application level request)** [HttpResponse] EncryptedData **(actual application level response)** So I can safely assume security is being applied. Now to the questions: **Question 1: What are the security settings?** I never told WCF of any membership provider. In fact I don't have any table (SQL or XML) of any usernames <-> passwords. So what kind of authentication is happening? Although WCF Test Client can authenticate as above, SoapUI doesn't pick up these Microsoft .NET defaults and has issues. SoapUI attempts clear text communications and then the server responds with an incorrect security token error. **Question 2: What is the most commonly practiced security model for SOAP 1.2?** Is it via certificates or username passwords or digest or **_** ? How are those credentials stored (SQL/XML?) and configured on the WCF server side?


Strengthening code with possibly useless exception handling

Is it a good practice to implement useless exception handling, just in case another part of the code is not coded correctly? ## Basic example A simple one, so I don't loose everybody :). Let's say I'm writing an app that will display a person's information (name, address, etc.), the data being extracted from a database. Let's say I'm the one coding the UI part, and someone else is writing the DB query code. Now imagine that the specifications of your app say that if the person's information is incomplete (let's say, the name is missing in the database), the person coding the query should handle this by returning "NA" for the missing field. What if the query is poorly coded and doesn't handle this case? What if the guy who wrote the query handles you an incomplete result, and when you try to display the informations, everything crashes, because your code isn't prepared to display empty stuff? This example is very basic. I believe most of you will say "it's not your problem, you're not responsible for this crash". But, it's still your part of the code which is crashing. ## Another example Let's say now I'm the one writing the query. The specifications don't say the same as above, but that the guy writing the "insert" query should make sure all the fields are complete when adding a person to the database to avoid inserting incomplete information. Should I protect my "select" query to make sure I give the UI guy complete informations? ## The questions What if the specifications don't explicitly say "this guy is the one in charge of handling this situation"? What if a third person implements another query (similar to the first one, but on another DB) and uses your UI code to display it, but doesn't handle this case in his code? **Should I do what's necessary to prevent a possible crash, even if I'm not the one supposed to handle the bad case?** I'm not looking for an answer like "(s)he's the one responsible for the crash", as I'm not solving a conflict here, I'd like to know, should I protect my code against situations it's not my responsibility to handle? Here, a simple "if empty do something" would suffice. In general, this question tackles redundant exception handling. I'm asking it because when I work alone on a project, I may code 2-3 times a similar exception handling in successive functions, "just in case" I did something wrong and let a bad case come through.


What are the advantages to using SQL query builders?

Are there any advantages to using a query builder, rather than using raw SQL? E.g.               $q->select('*')       ->from('posts')       ->innerJoin('terms', 'post_id')       ->where(...)      vs:               SELECT * FROM posts WHERE ...      I see that many frameworks use these kind of abstraction layers, but I fail to understand the benefits.


Good Practices of writing release notes

At the delivery of every version of software we have to write a release note. For example, here are some of the terms I add when I write a release note:   * Release Date   * Bug Solved Is that enough, or is there anything else?


How could I make automatic tests for GUI?

How can I check automatically what is seen and what not? Or at least, how can I organize some partly automatic tests? IDE: Eclipse (could use also IntelliJ Idea if necessary) Testing tool: Junit (again, could use something else if advised, but better if it is free) Application OS: Android Developer's OS: Linux (could change for MAC or Windows(reluctantly)) Language: Java All the work goes in the external device. No emulator. The application is a user wrapper for the firmware TV player, called as external activity. So, 70% of the code is for GUI. (The other 30% speak to servers and provides info to the GUI) Before I programmed the testing function myself, not using any tools. Now I have a tool at hand. But I can't imagine how could I test the UI, with the tool or without it. (Strictly said, with the Internet connections I have problems too, but I'll leave them probably for the other question.) The answer needn't be too platform-dependent, the principles and ideas will help, too. Of course, it is good to check, is some element in another and checked or not. Some regression checks would be nice for that. But I should also be sure that the element mentioned is not cut by some other elements and winks as I ordered by animation. The advices here: Is there a tool to test Java UI? won't help - there are only tools, not principles, and none of the tools could help in my situation.


Is it possible to check a client side application identity from server side?

Assume there is a web service which is visible publicly but it must be just responsive to a specific client application. Is there any mechanism to check client side application identity to prevent disallowed application to access the service? For instance, I have a web service which is called by my iOS application. I want to prevent others from calling my web service. Regarding the fact that others can decompile my client application and create another one which is working the same as mine, I think the only way to avoid unwanted access to the service is to check application identity on server to ensure the request comes from my own application. Is there any robust and secure way to do that?


Naming convention for higher order functions?

Is there a naming convention for higher order functions? That is, functions which return other functions. An example in Javascript:               function onlyDivisibleBy(div) { // <-- higher order function       return function (n) {         return n % div === 0;       }     }          var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];          arr.filter(onlyDivisibleBy(3)); // [0, 3, 6, 9]     arr.filter(onlyDivisibleBy(5)); // [0, 5]      I've tended to write it as above: that is, optimising for legibility at the invocation point (I'd read the last lines above as "filter the array to get items only divisible by 5"), however at the definition point away from the context in which it's used, it's not so easy to understand what this function does from its name.


Best process for product development and maintenance by a small team?

I'm going to be managing projects for a very small (2-5) senior developer team. They develop a subscription based web application. It has been in use for many years so at this point the work involves:   1. Developing new features and updates to existing features   2. Developing in-house tools and reports   3. Fixing bugs   4. Investigating customer service issues Production releases are sometimes determined by customer obligations, sometimes by competitive advantage, but for the most part are not time- critical. I'd like to have regular production releases to keep the product fresh -- once every 2 months or so. Since the team is so small, the developers themselves will have to be involved in designing, testing, deployment, and maintenance. Since we do not have a dedicated maintenance team I see the major challenge being development and planning disrupted by bug fixing and customer service issues. They can distract us during new feature development and disrupt the release schedule. My initial thought is to do the following:   1. Hire a junior programmer to buffer the senior developers from maintenance tasks. In between maintenance tasks this person can assist the senior devs.   2. Adopt a scrum style approach where we have a series of sprints leading up to a production release. This will allow us to keep the stakeholders in the loop and allow us to reflect and improve our process with each sprint.   3. Shortly following the release, which is when most bugs surface, the team can focus on design for the next release with the expectation that each one will likely get pulled into bug fixing. I'd love to hear your thoughts and lessons learned.


Multi-threaded application design

I'm currently planning a Windows service. It will be a multi-threaded application which will continuously check for database records and process them. My first thoughts were to set a number of max available threads and create new thread for each process. This works OK but since I'm creating a new thread for every new process I fear that its overhead will multiply if there are lots of records to process. My question is, is this a good design or would you recommend any other solutions? Here's what the application will do basically:   1. Check for available number of threads   2. If there are available threads check the database for records to process.   3. If there are records to process select top 100 of them   4. Create a new process   5. Call a web service for each record and update the record according to web service call result (This call+update usually take around 500ms so process will be live for about 50 seconds)   6. Continue to step 1 This is currently what I am doing:               timer1.Tick += Tick();          private void Tick()     {         //do some text logging         //do some TextBox updating     }          int MaxThreads = 10          while(true)     {         if(ThreadCount < MaxThreads)         {             new Thread(() => Process()).Start();             ThreadCount++;         }         else         {             Thread.Sleep(10000);         }     }          private void Process()     {         //call ws         //update records              ThreadCount--;     }


How to release project under public domain?

I'm currently working on project, which is going to demonstrate how widgets can be done with Context Framework. I will also publish the source code. In this case I want to give users as much freedom as possible, so that they can freely copy-paste, modify and also relicense whatever code they reuse. So, how do I mention that in the project? Are the some ready-made licences etc. that are suitable for this?


Dealing with multiple business requirement streams without compromising team size

A business has five discrete streams of business requirements to be implemented in software. There is a team of ten developers. A "naiive" organisational solution is to split the team into five "teams" of two (one per requirements stream). But I feel this compromises the integrity of the team (making teamwork more difficult, causing silo effects, making communication harder etc). Has anyone any insight into how best organise a developer team like this to deliver against multiple requirement streams? Is it workable to have fewer development teams than there are requirements streams?


A description for a changing-wording-of-a-website framework

I have built a Ruby gem, which allows programmer (or whoever) to change wording on their Rails website. When the edit mode is activated, every text on the website will have an edit icon. User can click on that edit icon and change the corresponding text immediately. It works with text, attributes of any element, select element, and string in Javascript. Now I don't know how to describe it succinctly. Right now the description is "WhowishWord facilitates the process of changing wording of a website". I think the description is bad and vague. Maybe there is a regular keyword for this kind of task (changing wording) that I do not know. Could someone help me, please?


What a Site Needs To Be Considered a WebApp?

I've been looking at the Chrome Store and I started to think about developing some nice stuff to publish there, since I have a machine installed with Chromium and I see the WebApp market a lot better than the platform-specific one. But what a site really needs and how it should be designed to be considered a WebApp?


Is there an anti pattern for historically grown software?

Is there an anti pattern that describes a historically grown software system where multiple developers just added new features to the system but no one really kept an eye on the overall architecture nor were refactorings ever done? I think this happens when management/customer asks for new feature constantly and no one ever refactors anything but just adds on to what other developers haven done before. A reason could also be that the developer is just overwhelmed with the software system and does not really understand how it currently works and then just adds/glues his code at the very end (instead of refactoring the code and changing it.) So over time it's getting harder and harder to maintain the system. (I wonder if there are pictures for these kind of anti pattern to make this more clear to none programming folks - like a car that was built by just adding more and more features without thinking of the overall design. Like someone has the need to tow trailers while riding backwards and then an engineer just welds a tow bar to the front of the car. Job done. But now the cowl doesn't open anymore.)


Is there a software license "for personal use only" and against any derivative work

I want to release an npm (NodeJS) module that will be a development dependency for extensions built for my product (will be used in testing). I don't want this module to be used in any released derivative work (commercial or free, open or closed source). Is there an existing suitable license that I can use?


Programming languages that improve your programming skill in general?

What languages would you suggest a programmer to learn, not because they will have a lot of use of the language (but they may have), but because it will improve one's programming skill in general and let one think in a different (and possibly better) way?


Starting as a developer what are the possible career steps?

I would like to know what kind of **jobs/roles** one could expect on their career path if they start as a developer. I also want to know **how many years** you'll be expected to stay in the same role until you progress to the next level. The career path is of course, based on how good you do your job, the company etc. but assume a normal person who balances life and family with career. Some examples of roles that I have in may head: developer, senior developer, architect, project manager etc.


Using SVN along with WAMP

I would like to run SVN server on my local machine along with WAMP. All SVN server binaries include Apache. Whereas I don't need Apache as I'm already running WAMP. Please let me know if there are any installs available that includes only the SVN server. If there are none available, shall I go ahead with what's available? And how would I do that without breaking anything. PS: I tried CollabNet and VisualSVNServer. Both includes Apache.


Legal issues with an NDA that I do not want to sign

I've been given a non-disclosure agreement (NDA) to sign by my current employer that I do not want to sign. It is incredibly open ended and I feel that it should have been a condition of my initial employment agreement, which I signed three weeks ago. The document contains very many definitions in the form of "including but not limited to," and "directly or indirectly." As well, it states that:   * I agree that any breach of the contract would inflict irreparable harm on the company (I agree that a breach may result in harm to the company but not necessarily irreparable harm).   * Should the document be amended any time in the future and I refuse to sign the amendment that I would be in violation of its terms.   * Everything I develop while under the company's employment is its property (neglecting to say whether what I develop on my own time, distinctly from my work, is my own).   * After my employment ends at the company I would be required to continue my duties there to assist in the perfection of its software, that I would not be allowed to perform any duties directly or indirectly related to my duties there for one year after my employment at the company ends (would I not be allowed to engineer software for a year?).   * Should the company decide to prosecute me for breach of contract that I agree not to defend myself, and that all terms in the document would be transferred to any company which purchases the one I work for without my consent. In short, they would legally own me for life and could absolutely destroy me for any reason they deemed fit. Are there any legal arguments that I could use to defend myself against signing the contract? For example, the fact that the NDA was not part of my initial employment agreement or that the document is intentionally abstract and vague to allow them to fill in the blanks any way they please? The company hosts the entirety of its source code on a site which employs a publicly accessible SCM and greatly embraces open source software -- the chances that I would ever come in contact with information that could legally be considered a "trade secret" or "confidential information" is very slim, so why would I need to sign the NDA? I do not believe that many of the employees there actually took the time to understand the NDA before they signed it, and know for a fact that a few of them did not. Are the terms of this agreement commonplace among the software engineering community?


Writing in C for Performance?

I know I have quite frequently heard that C typically has a performance advantage over C++. I didn't really think anything else of it until I realized that MSVC doesn't even seem to support the newest standard of C, but the newest it supports it C99 (as far as I know). I was planning on writing a library with some code to render in OpenGL so I could reuse it. I was planning to write the library in C since any performance increase is welcome when it comes to graphics. But would it really be worth it? The code using the library would likely be written in C++ and I prefer to code in C++ generally. However, if it would produce even a small difference in performance, I would likely go with C. It may also be noted that this library would be something that I would make to work across Windows/OS X/Linux, and I would likely compile everything natively (MSVC for Windows, Clang or GCC for OS X, and GCC for Linux...or possibly Intel's compilers for everything). I've looked around and I've found some benchmarks and such, but everything I've seen has dealt with GCC rather than MSVC and Clang. Also, the benchmarks don't mention the standards of the languages used. Anyone have any thoughts on this?


Explicit or implicit looping?

Why or when is "explicit" preferred when implicit solutions often are more readable and less code? It says "explicit is better than implicit" when for example an implicit loop is better than an explicit loop isn't it?               for every in all:       every.updated = True      The above looks implicit to me and better than an explicit counter since a counter is another thing that can go wrong and why not leave to the compiler or other environment instead of requirement an explicit counter variable:                 for(int i=0, i<a.length, i++)     ...      And there are languages where all looping is "implicit" - what does it mean and when is it preferred? And not explicitly setting a value to `null`or `None` or likewise seems better to me and I want to rewrite code when I "solve" a requirement by explicitly setting `return null` or `String name = null` since I think being explicit about what should be null and None should have a more clear solution such as only use a variable if it's needed and if I write return null somewhere I'm probably doing it wrong. When I was writing Java I found myself writing `return null` and declaring values as null at some places and I didn't like it and could rewrite it even though the case where I put `return null` was reached only in case of error. I asked the guru at work whether we ever should declare a variable to null, isn't defaults much better? I'd be glad to know your thoughts about this. An example where it _is_ better to be explicit I can think of is declaring a list and explicitly declaring what type is in the list is better than just a list of objects e.g. it's preferred to declare `ArrayList<ArrayList>` instead of just an ArrayList if we know that it's a list of lists.


How to take things step by step

This is about the third time I've had to write software to control a cellular modem. For those unfamiliar with the process, you have a sequence of steps you have to take. Each step takes a certain amount of time, and there's a few responses you should receive in that amount of time. There are also some responses you can receive at any time, regardless of the step you are on. Based on the response you have to go to another stage in the process. If it times out, you have to go to a different stage. In some cases, steps are attempted multiple times before going to another stage. These have to be non-blocking functions, which I can run as a task on a single threaded machine. So the main program would be calling this `modemTask()` a few hundred times a second, it checks whether it needs to do something, then performs a function if needed, and exits. In the past I've written this as a simple `switch` based state machine, with enumerated stages, somewhat like the following:               switch(stage){        case Power:           powerOn();                 // Turn the modem on           nextstage = ResetCmd;      // Go perform a reset           attemptsLeft = 5;          // Send the reset command up to five times           break;        case ResetCmd;           modem.write("ATZ\n");      // ATZ - reset           attemptsLeft--;            // Use one of our attempts           nextstage = ResetReply;    // Next wait for a response (should be OK)           timeout = millis() + 5000; // Wait for up to 5 seconds each attempt           break;        case ResetReply;           if(receivedResponse() == OK)     // Success           {              nextStage = NetworkAttachCmd; // Attach to the cellular network           } elseif(receivedResponse() == ERROR || timeout < millis())           {        // If we get an error or timeout, reattempt if we can, power on if we can't              if(attemptsLeft > 0)              {                 nextStage = ResetCmd;              } else {                 nextStage = Power;              }           }            break;        case NetworkAttachCmd:        ...     }     stage = nextstage;               // Assign stage indirectly for debug purposes - nice to know where we came from at this point      It's difficult to keep track of the whole flow of the system, inserting an additional step requires changes to the steps before and after, and it just seems like there should be an easier way. The largest one I've had to design had fewer than 60 stages, so it's not unmanageable, but I can't help but think that there's a better strategy or pattern for this type of work. While I use a few `#define` for most timeouts and attempts, it would be a bit nicer if this weren't embedded in the state machine. Perhaps a structure of some sort could be made to hold each state, but since the responses vary it seems just as complicated. Most steps will have a simple "OK" but some contain status and data that have to be acted on, where the stage will change based on the exact response.


Why is testing MVC Views frowned upon?

I'm currently setting the groundwork for an ASP.Net MVC application and I'm looking into what sort of unit-tests I should be prepared to write. I've seen in multiple places people essentially saying 'don't bother testing your views, there's no logic and it's trivial and will be covered by an integration test'. I don't understand how this has become the accepted wisdom. Integration tests serve an entirely different purpose than unit tests. If I break something, I don't want to know a half-hour later when my integration tests break, I want to know immediately. **Sample Scenario :** Lets say we're dealing with a standard CRUD app with a Customer entity. The customer has a name and an address. At each level of testing, I want to verify that the Customer retrieval logic gets both the name and the address properly. To unit-test the repository, I write an integration test to hit the database. To unit-test the business rules, I mock out the repository, feed the business rules appropriate data, and verify my expected results are returned. **What I'd like to do :** To unit-test the UI, I mock out the business rules, setup my expected customer instance, render the view, and verify that the view contains the appropriate values for the instance I specified. **What I'm stuck doing :** To unit-test the repository, I write an integration test, setup an appropriate login, create the required data in the database, open a browser, navigate to the customer, and verify the resulting page contains the appropriate values for the instance I specified. I realize that there is overlap between the two scenarios discussed above, but the key difference it time and effort required to setup and execute the tests. If I (or another dev) removes the address field from the view, I don't want to wait for the integration test to discover this. I want is discovered and flagged in a unit-test that gets multiple times daily. I get the feeling that I'm just not grasping some key concept. Can someone explain why wanting immediate test feedback on the validity of an MVC view is a bad thing? (or if not bad, then not the expected way to get said feedback)


Is "pass by value" synonymous with "functional programming" ?   1. Are there any iterative programming languages that are (largely) "pass by value"?   2. Are there any functional programming languages that are (largely) "pass by reference"? Thanks.


How does compiler handle exceptions that are implicit? Looking for design strategies

Throughout the function handleException, the exception encountered is implicit. How does the compiler handle such implicit passing of exceptions? [For e.g. in C++ methods, **this** pointer is passed to account for the current object. My question is how does a compiler handle exceptions internally - handleException has no arguments.]                void handleException()      {        try {          throw;        }        catch (MyException& e) {          ...code to handle MyException...        }        catch (YourException& e) {          ...code to handle YourException...        }      }           void f()      {        try {          ...something that might throw...        }        catch (...) {          handleException();        }      }


Java Heap Allocation Faster than C++

I already posted this question on SO and it did ok. It was unfortunately closed though(only needs one vote to reopen) but someone suggested I post it on here as it is a better fit so the following is literally a copy paste of the question * * * I was reading the comments on this answer and I saw this quote. > Object instantiation and object-oriented features are blazing fast to use > (faster than C++ in many cases) because they're designed in from the > beginning. and Collections are fast. Standard Java beats standard C/C++ in > this area, even for most optimized C code. One user (with really high rep I might add) boldly defended this claim, stating that   1. heap allocation in java is better than C++'s    2. and added this statement defending the collections in java  > And Java collections are fast compared to C++ collections due largely to the > different memory subsystem. So my question is can any of this really be true, and if so why is java's heap allocation so much faster.


What popular program is used to develop GUI in C++?

I'm asking this question because my creativity can only go so far with console programs in C++. I need to know what program/software the majority of c++ software developers out there use develop GUI in C++. I'm heading into College in a couple weeks and want to major in Computer programming and I really would like that head start. Thanks.


Testing for Non Programmers

I would like to get my younger brother, who can't program, to test some code I am writing from requirements I provide him in documentation. Is there a way to get him going quickly? Ideas? Please and thank you.


What is Zend's relationship with PHP?

What exactly is Zend's relationship to PHP? I don't mean the framework but the company itself. Are they the gatekeepers or guardians of sort? I've just been reading up on PHP, and other than requiring knowledge of C to extend it you apparently need to learn the Zend APIs. But when you first start out with PHP you don't need to know anything "Zend", and the same goes for non-Zend frameworks like Cake and CodeIgniter. So I'm confused and curious about when knowing things Zend begins to matter in using PHP.


Oracle owns Java but Google is using Java?

Ok, I don't get it. What does "Oracle owns Java" mean? Google is definitely using Java in Google App Engine, does that mean that Google have to pay Oracle for doing so?


Peer programming and experience sharing

There was a mention in the Java Posse Podcast about how teams should be divided up into pairs. However, there was a mention from the lady on the podcast that: "Pairs should be mixed up [sic]" (an encouragement for diversity) I understand the benefits of pair programming, but what benefit is there to intentionally mix people up. To me it would seem that it would be better to take a genetic algorithm like approach to find optimal groups to generate pairs. An example: Let's say you have a tax developer and a front end developer how would either of these guys benefit from the intentional mixing of peer groups? Why did her assertion go unchallenged? (I got the sense that she was advising that it should go cross groups and development tiers)


How do I succeed as a lead developer?

I have become the lead developer in a particular project, but I'm having difficulty focusing on the big picture and making sure all pieces of the project are covered. What should I keep in mind when managing this project? How can I make sure everything gets handled the way it should?


Scrum Daily meeting: Punctuality over Full team presence?

My understanding is that a Daily Scrum meeting should be very quick, hosted in a friendly way and that it requires all the team members present. Because it is objective is to have everyone up to date with what everybody else is doing. I like Scrum Daily Meetings that are held like that. In my latest project our Daily Scrums are more like a Status Update meeting. Although the position is that we are holding Scrums and practicing proper Agile. We are a distributed team, in 2 different countries, and the people that is in the same Country are not in the same office. As consequence we have virtual Scrums. The problem is that our meetings always start on time, many people calls before the actual start time, so they actually start at the very first second of the meeting. Without any tolerance for small delays. For example the last time we were on the phone and the person coordinating the meeting checked if everyone was on, and we said one of our team members was not on yet but he was calling. And I was told to start sharing without waiting for my team member. Also everyone has a lot of meetings, and sometimes they are back to back with the Scrum meeting, so it is understandable if they arrive during the first or second minute of the meeting. Is that the normal for teams practicing Daily Scrums? It is the first time that happens to me. I can not find any bibliography directly about it. Although the presence of all team members is stressed, it is stressed also that the meetings should always start at the same time. But I imagine there can be a small delay tolerance. I even read on a blog someone suggesting that the Scrum Master can place penalties if someone arrives "5 seconds" late. I thought the Scrums were supposed to be friendly, and having a penalty like that seems counter productive. What is the recommended approach in a situation like this?


How would one start a website with robust and scaleable hosting?

This question is about hardware and hosting, and how to "bootstrap" them. If you built a really great website, how could you have it hosted at low cost but so that it reassures customers that their data is safe and available. As an example, what if I have a web application I developed for small companies to use for their accounting, a replacement for Quickbooks. Aside from getting a bunch of money from VCs or Angels, how would you be able to host this so that you could guarantee your customers that their data won't be lost, and the site will always be up so that they can always get to their data?


Is Haskell good at teaching fundamentals of mathematics?

I'm involved in teaching mathematics to classes with requirements such as AS and A level Mathematics specification. Class books normally provide examples of computer software applied to mathematics tasks, but they are normally based on software applications like mathlab, mathematica or derive. Even when a _real_ programming language is used, it is normally old fashoned language like Pascal. And this is really sad in my opinion. Because, Haskell is famous for his feeling with mathematics, and because I'm interested in it as well, I'd like to ask whether Haskell is a good choice as extension exercise method for students of a first year university class. Typical subjects are functions, caclulus, limits, but also linear algebra for example. I've intermediate knowledge experience in programming (c#, ruby, powershell, javascript, tex) and also have already approached functional programming with XSLT. Answers will be upvoted responsibly. Verbose answers including also some basic examples of Haskell code applied to mathematics, such as linear algebra (e.g. vectorial space), polynomials, solving linear equations are much appreciated and targeted as the wanted one.


Dynamically load and call delegates based on source data

Assume I have a stream of records that need to have some computation. Records will have a combination of these functions run `Sum`, `Aggregate`, `Sum over the last 90 seconds`, or `ignore`. A data record looks like this:               Date;Data;ID      **Question** Assuming that ID is an `int` of some kind, and that int corresponds to a matrix of some delegates to run, how should I use C# to dynamically build that launch map? I'm sure this idea exists... it is used in Windows Forms which has many delegates/events, most of which will never actually be invoked in a real application. The sample below includes a few delegates I want to run (sum, count, and print) but I don't know how to make the quantity of delegates fire based on the source data. (say print the evens, and sum the odds in this sample)               using System;     using System.Threading;     using System.Collections.Generic;     internal static class TestThreadpool     {              delegate int TestDelegate(int  parameter);              private static void Main()         {             try             {                 // this approach works is void is returned.                 //ThreadPool.QueueUserWorkItem(new WaitCallback(PrintOut), "Hello");                      int c = 0;                 int w = 0;                 ThreadPool.GetMaxThreads(out w, out c);                 bool rrr =ThreadPool.SetMinThreads(w, c);                 Console.WriteLine(rrr);                      // perhaps the above needs time to set up6                 Thread.Sleep(1000);                      DateTime ttt = DateTime.UtcNow;                 TestDelegate d = new TestDelegate(PrintOut);                      List<IAsyncResult> arDict = new List<IAsyncResult>();                      int count = 1000000;                      for (int i = 0; i < count; i++)                 {                     IAsyncResult ar = d.BeginInvoke(i, new AsyncCallback(Callback), d);                     arDict.Add(ar);                 }                      for (int i = 0; i < count; i++)                 {                     int result = d.EndInvoke(arDict[i]);                 }                           // Give the callback time to execute - otherwise the app                 // may terminate before it is called                 //Thread.Sleep(1000);                      var res = DateTime.UtcNow - ttt;                 Console.WriteLine("Main program done----- Total time --> " + res.TotalMilliseconds);             }             catch (Exception e)             {                 Console.WriteLine(e);             }                  Console.ReadKey(true);         }                   static int PrintOut(int parameter)         {             // Console.WriteLine(Thread.CurrentThread.ManagedThreadId + " Delegate PRINTOUT waited and printed this:"+parameter);             var tmp = parameter * parameter;             return tmp;         }              static int Sum(int parameter)         {             Thread.Sleep(5000); // Pretend to do some math... maybe save a summary to disk on a separate thread             return parameter;         }              static int Count(int parameter)         {             Thread.Sleep(5000); // Pretend to do some math... maybe save a summary to disk on a separate thread             return parameter;         }              static void Callback(IAsyncResult ar)         {             TestDelegate d = (TestDelegate)ar.AsyncState;            //Console.WriteLine("Callback is delayed and returned") ;//d.EndInvoke(ar));         }          }


Is it a responsibility of the software developer to understand what the customer meant with his request?

Kind of a yes / no question and why? **Is it the responsibility of the software developer to understand what the customer meant with his/her request or is it the responsibility of the customer to properly explain his/her request to the developer?** The situation at work is currently "the customer already explained us, what he wants. It's your responsibility to understand the request, not ask more questions". While English is not my strong suite, all the requests are written in obscure English with misplaced words and hard to understand sentences, some requests assume previous understanding of the system on my part. I'm the 3rd or 4th developer of the system (the last developers quit the job) and that might be the reason the customer expects some understanding on the developers side. The system itself is quite messy both in the UI and source code level. This looks like monkey coding to me - code and hope you get the request right, while not actually understanding the request. I'm actually thinking about quitting the job, but haven't yet, given I'm not sure about who's right and who's wrong.


When should I use parallelism?

After asking this question, I got to realize that parallelism may not always be good. So far I can see that parallelism (under c#) is   * A little complicated code-wise   * Will probably insert some concurrency complications   * Will not always be faster I am looking inside parallelism because I want to make existing and new applications work faster, but now I see that it is no silver bullet. When should I use it? are there any best practices? Is it just a waste of time in most cases? Is it suitable for a specific kind of applications? I am looking forward for your insights on this matter.


How can Swift be so much faster than Objective-C in these comparisons?

Apple launched its new programming language Swift at WWDC14. In the presentation, they made some performance comparisons between Objective-C and Python. The following is a picture of one of their slides, of a comparison of those three languages performing some complex object sort: ![enter image description here](http://i.stack.imgur.com/wcdXk.jpg) There was an even more incredible graph about a performance comparison using the RC4 encryption algorithm. Obviously this is a marketing talk, and they didn't go into detail on how this was implemented in each. I leaves me wondering though:   1. How can a new programming language be so much faster?    2. Are the Objective-C results caused by a bad compiler or is there something less efficient in Objective-C than Swift?    3. How would you explain a 40% performance increase? I understand that garbage collection/automated reference control might produce some additional overhead, but this much?


Why is using 'final' on a class really so bad?

I am refactoring a PHP OOP legacy website. I am so tempted to start using 'final' on classes to "`make it explicit that the class is currently not extended by anything`". This might save lots of time if I come to a class and I am wondering if I can rename/delete/modify a `protected` property or method. If I _really_ want to extend a class I can just remove the final keyword to _unlock it_ for extending. I.e If I come to a class that has no child classes I can record that knowledge by marking the class a final. The next time I come to it I would not have to re-search the codebase to see if it has children. Thus saving time during refactorings. It all seems like a sensible time saving idea.... but I have often read that classes should only be made 'final' on rare/special occasions. Have you ever treated `final` liberally and had bad experiences or is this 'fear of final' just a myth. Maybe it screws up Mock object creation or has other side effects that I am not thinking of. What am I missing?


Avoid ELSE when setting a variable?

Which of these styles do people prefer?               string mystring = "defaultvalue";     if (condition)        mystring = "othervalue";      VS               string mystring = null;     if (condtion)        mystring = "othervalue";     else        mystring = "defaultvalue";      VS               mystring = condition? "othervalue" : "defaultvalue";


Interview Questions in OOP

I faced the below interview questions in OOP under PHP language. Kindly clear my clarifications regarding this. I am very confused. As i am a beginner to OOP i got too confused. Could anyone clarify these things clearly?   1. **Difference between Abstract class and interface.** Interviewer : Let us consider abstract class contains three abstract methods such as a,b,c and interface contains three methods a,b,c. In this case these do the same functionality. Then why are going for abstract and why are we going for interface. Me : ?   2. **static keyword.** Interviewer: We call static method without creating object by using scope resolution operator in PHP. As well as we can able to call concrete methods also. Then what is need of static keyword there? Me : ....   3. **final keyword.** Interviewer: Give me any scenario of using final keyword. Me : For db connection related method Interviewer: Other than that? Me: ...   4. **Constructor.** Interviewer: What is the use of constructor? Me : There is no need for object to access this. It will call automatically when the class calls. Interviewer: Other than that? Me : .... Thanks in advance...


Why Aren't There New Versions of C?

While many other languages have rapid development, such as Python, which has come out with a whole new version in the past few years, or to use a framework, Rails, which evolves super-fast (A book that was published in early 2011 is now obsolete), it seems that there are no updates for C. Why is this?


Overcoming slow problem solving due to increased knowledge of what might go wrong

This has been troubling me for some time, and I'd really appreciate the input of other professionals. Short background: I started programming when my parents bought me my first computer in 1988 (at age 14, I'm 39 now). I followed a couple of other career paths before finally becoming a professional programmer in 1997. Late bloomer, perhaps, but that's how it was. I'm still happy with my choice, I love programming, and I consider myself good at what I do. Lately, I've been noticing that the more experience I gain, the longer it takes me to complete projects, or certain tasks in a project. I'm not going senile yet. It's just that I've seen so many different ways in which things can go wrong. And the potential pitfalls and gotchas that I know about and remember are just getting more and more. Trivial example: it used to be just "okay, write a file here". Now I'm worrying about permissions, locking, concurrency, atomic operations, indirection/frameworks, different file systems, number of files in a directory, predictable temp file names, the quality of randomness in my PRNG, power shortages in the middle of any operation, an understandable API for what I'm doing, proper documentation, etc etc etc. In short, the problems have long since moved from "how do I do this" to "what's the best/safest way of doing it". The upshot is that it takes me longer to finish a project than a novice. My version may be rock solid, and as impenetrable as I know how to make it, but it takes longer. The "create file" example above was just that, an example. Real tasks are obviously more complex, but less suited for a generic question like this one. I hope you understand where I'm going with this. I have no problem coming up with efficient algorithms, I love math, I enjoy complex subjects, I have no difficulties with concentration. I think I do have a problem with experience, and consequently with a fear of errors (intrinsic or extrinsic). I spend almost two hours a day reading up on new developments, new techniques, languages, platforms, security vulnerabilities, and so on. The conundrum is that the more knowledge I gain, the slower I am in completing projects. How do you deal with this?


.NET silverlight development tools

What tools are necessary when developing efficiently with Silverlight 4? VS 2010 is a gimme, but what version? Is Pro enough? Premium? What about Expression Blend/Web/Both? When considering VS 2010, premium comes with an MSDN subscription but it's at the high end of the budget. It makes sense if Expression comes with it though. It's for a one man development show, making an LOB app that will integrate video/audo and mic/webcam equipment.


How does aggregation work when databases are involved?

So I'm reading a book on Design Patterns (Design Patterns Explained 2nd Edition), and all throughout the book it says to "favor aggregation over inheritance". I'm trying to wrap my head around trying to design something, and I feel so stupid. So conceptually, I have `Recruiters`. I figured these recruiters can be an abstract class, because I have a couple different types of recruiters... full time and part time. The thing is, I want each recruiter to be able to have references to other recruiters because they might work together and need to share and combine information. Each Recruiter would have one or more `Regions` that they oversee, perhaps sharing it with other Recruiters. All the region is a conceptual aggregate of `SubRegions`. The SubRegions define places that fall along certain geographical boundaries. These contain some numerical statistic information about recruitments for that SubRegion as a whole. The Subregions consist of `Recruitments`, which contains detailed information about particular recruiting events for a SubRegion. They also contain other statistical information that makes sense to be under Recruitments(because they're very specific to the Recruitment), but not under SubRegions. Every time some information from the recruitment is updated, it needs to create a new record of that transaction so I can keep a history of how the numbers are adjusting. Now, I want all of these to be able to be stored in a database. I am very naive when it comes to database design and structuring, especially when it comes to dealing with abstract classes and interfaces which are new to me. Everything in the database is going to be linked in some way, among different tables. Say, the Recruiters are going to be a table, and there is going to be a Region table, a SubRegion table, and a Recruitment table. Where do I need to put the logic, and how do I put it, such that I can make sure I can save everything out to the database, keyed together nicely, but loosely coupled in the code?


Is it safe to use CamelCased file names?

I'm developing a simple CMS which I'd like to make it open source. For the file structure, do you think it's safe to use names like:               AppData     FileUploads      instead of               app-data     file-uploads      ? Because I heard some servers have problems with the camelCase.


If I use multiple third party components, using several different open source licenses, how should I attribute them?

I'm developing a Java application that utilizes several third party open source libraries. I'm adding a section to my app's "About" dialog that lists the components and their license notices. For those that use the same license, do I have to repeat the same license text for each one? For example, I use several components that are all released under the Apache 2 license. Do I have to list the Apache 2 license terms for each one, or just say "Foo, Bar, and Baz are used under the terms of the Apache 2 License" and list the actual terms once? Thanks. Just want to do the right thing.


In integration testing, do you use the data access objects for setup and validation or a different data access method?

When writing integration tests for business logic objects and data access objects, what makes the most sense to use for setup and validation? In my case, I'm using an ORM in the implementation of my data access interface that will be used in production, and I plumb that ORM implementation together with the business logic objects for integration testing. Given that the ORM implementation is tested separately using INSERT and SELECT statements for setup and validation, is it best for integration testing setup and validation to use the ORM implementation of the data access interface, to use the ORM directly, to use those INSERT and SELECT statements, or to do something else, **_edit: and why?_** The ORM in this case is NHibernate, the ORM implementation of the data access interface is a simple pass-through to NHibernate's LINQ provider that also provides simple pagination and sorting mechanisms. I'm curious to know what you think, either generally or with this specific scenario. _**edit:_** I'm not looking to know what DAO I should connect to the BL objects. That _clearly_ should be the same DAO that will be used in production. The question is about the mechanism used to put data into the database to set up the test _before_ the business logic function is tested. Presumably, the same mechanism would be used to poll the database _after_ the business logic function is tested. Here's some very high-level pseudo-code to demonstrate what I mean:               MyIntegrationTest()     {         Foo fooBefore = GenerateFooForTesting();         SomehowInsertIntoDatabase(foo); // What should be used here and why?              // Plumb things together; actually done using IoC, not hard-coded.         DaoFactory realDaoFactory = GetRealDaoFactory();         BizFactory realBizFactory = GetRealBizFactory();         realBizFactory.DaoFactory = realDaoFactory;              BusinessLogicObject biz = realBizFactory.BuildBusinessLogicObject();         biz.DoBusinessWithFooById(fooBefore.Id);              Foo fooAfter = SomehowGetFooFromDatabase(fooBefore.Id); // Same question.              Assert.AreEqual(5, fooAfter.SomethingThatShouldBeFiveAfterBusinessIsDone);     }


Language-agnostic libs every programmer should consider learning?

Assuming the language provides it, what are some things to do or libs to use that every programmer should know? My list would be   * Regular Expressions   * Named Pipes   * standard IO (std in/out/error)   * Executing outside executables (like imagemagik and your own scripts)   * How to grab an http page as a string (mostly for updates and grabbing configs from servers) I have a similar questions about tools. Also i am looking for specific answers. i dont want answers that can be done in different ways (such as learn how to synchronize threads). I know how to do the above in 3+ languages. There always seems to be things programmers dont know how to do which can make their lives easier. For the longest time i didnt know what regular expression was (although i did hear of it) and I was surprised how many people who tried to make a toolchain or complex app and did not know how to (or that you could) get the stdout from an exe they launched (they checked for errors in a very weird way or just didnt and hope it produce the expected results). What do you think useful, not well known and should be something every senior (or starting out) programmer should know?


Can a candidate be judged by asking to write a complex program on "paper"?

Sometime back in an interview, I was asked to write following program: * * * _In a keypad of a mobile phone, there is a mapping between number and characters. e.g. 0 & 1 corresponds to nothing; 2 corresponds to 'a','b','c'; 3 corresponds to 'd','e','f'; ...; 9 corresponds to 'w','x','y','z'_. _User should input any number (e.g. 23, 389423, 927348923747293) and I should store all the combinations of these character mapping into some data structure. For example, if user enters "23" then possible character combinations are_ : > ad, ae, af, bd, be, bf, cd, ce, cf _or if user enters, "4676972" then it can be_ , > gmpmwpa, gmpmwpb, ..., hnroxrc, ..., iosozrc * * * Interviewer told that people have written code for this within 20-30 mins!! Also he insisted I have to **write on paper**. If I am writing a code then my tendency is as of I am writing production code, even though it may not be expected from me. So, I always try to think all the aspects like, _optimization, readability, maintainability, extensible_ and so on. Considering all these, I felt that I should be writing on PC and it needs decent 2 hours. Finally after 25 mins, I was able to come up with just the concept and some shattered pieces of code (not to mention of my rejection). My question is not the answer for the above program. I want to know that **is this a right way to judge the caliber of a person** ? Am I wrong / too slow in the estimates ? Am I too idealistic ?


How should I handle a redirect to an identity provider during a web api data request

# Scenario I have a single-page web app consisting purely of html, css, and javascript. After initial load and during use, it updates various views with data from one or more RESTful apis via ajax calls. The api calls return data in a json format. Each web api may be hosted on independent domains. # Question During the ajax callout, if my authorization token is not deemed valid by the web api, the web api will redirect me (302) to the identity provider for that particular api. Since this is an ajax callout for data and not necessarily for display, i need to find a way to display the identity provider's authentication page. It seems that I should trap that redirect, and open up another view to display the identity provider's login page. Once the oauth series of redirects is complete, i need to grab the token and retrigger my ajax data call with the token attached. Is this a valid approach, and if so are there any examples showing the ajax handling of the redirects?


Why do websites restrict the number & choice of characters in a password?

Registering on an insurance company's website right now, and my password is 16 characters long, using a nice variety of letters, numbers, special characters, etc. However, here's their list of restrictions: > Note your password: > >   * must be between 6 and 12 characters >   * must not contain spaces, special/international characters >   * must not contain your user name, first name or last name >   * is case-sensitive >   * should contain at least 1 number and 1 letter > I can understand minimum 6 characters, not allowing parts of your name, being case-sensitive, and needing at least 1 number and letter. The part I don't get is restricting your choice of characters you can use, and having an upper bound. Why do websites do this? The only thing I can think of it they don't know the basics of hashing a password, which would secure it better than anything, and get rid of any security concerns. If I choose to type `DELETE FROM users WHERE 1=1` as my password, I should be allowed to. PHP's MD5 hash of it becomes `fe5d54132b51b7d65ab89b739b600b4b` which I don't think will harm anything.


How to write good code with new stuff?

I always try to write easily readable code that is well structured. I face a particular problem when I am messing around with something new. I keep changing the code, structure and so many other things. In the end, I look at the code and am annoyed at how complicated it became when I was trying to do something so simple. Once I've completed something, I refactor it heavily so that it's cleaner. This occurs after completion most of the time and it is annoying because the bigger the code the more annoying it is the rewrite it. I am curious to know how people deal with such agony, especially on big projects shared between many people ?


How do you cope with change in open source frameworks that you use for your projects?

It may be a personal quirk of mine, but I like keeping code in living projects up to date - including the libraries/frameworks that they use. Part of it is that I believe a web app is more secure if it is fully patched and up to date. Part of it is just a touch of obsessive compulsiveness on my part. Over the past seven months, we have done a major rewrite of our software. We dropped the Xaraya framework, which was slow and essentially dead as a product, and converted to Cake PHP. (We chose Cake because it gave us the chance to do a very rapid rewrite of our software, and enough of a performance boost over Xaraya to make it worth our while.) We implemented unit testing with SimpleTest, and followed all the file and database naming conventions, etc. Cake is now being updated to 2.0. And, there doesn't seem to be a viable migration path for an upgrade. The naming conventions for files have radically changed, and they dropped SimpleTest in favor of PHPUnit. This is pretty much going to force us to stay on the 1.3 branch because, unless there is some sort of conversion tool, it's not going to be possible to update Cake and then gradually improve our legacy code to reap the benefits of the new Cake framework. So, as usual, we are going to end up with an old framework in our Subversion repository and just patch it ourselves as needed. And this is what gets me every time. So many open source products don't make it easy enough to keep projects based on them up to date. When the devs start playing with a new shiny toy, a few critical patches will be done to older branches, but most of their focus is going to be on the new code base. How do you deal with radical changes in the open source projects that you use? And, if you are developing an open source product, do you keep upgrade paths in mind when you develop new versions?


Type of AI to tackle this problem?

I posted this on stackoverflow but want to get your recommendations as well as a user on overflow recommended I post it here. I'm going to say from the beginning that I am not a programmer, I have a cursory knowledge of different types of AI and am just a businessman building a web app. Anyways, the web app I am investing in to develop is for a hobby of mine. There are many part manufacturers, product manufacturers, upgrade and addon manufacturers etc. for hardware/products in this hobby's industry. Currently, I am in the process of building a crowd sourced platform for people who are knowledgeable to go in and mark up compatibility between those parts as its not always clear cut if they are for example: Manufacturer A makes a "A" class product, and manufacturer B makes upgrade/part that generally goes with class "A" products, but is for one reason or another not compatible with Manufacturer A's particular "A" class product. However, a good chunk (>60%-70%) of the products/parts in the database can have their compatibility inferenced by their properties, For example: Part 1 is type "A" with "X" mm receiver and part 2 is also Type "A" with "X" mm interface and thus the two parts are compatible.. or Part 1 is a 8mm gear, thus all bushings of 8mm from any manufacturer is compatible with part 1. Further more, all gears can only have compatibility relationships in the database with bushing and gear boxes, but there can be no meaningful compatibility between a gear and a rail, or receiver since those parts don't interface. Now what I want is an AI to be able to learn from the decisions of the crowdsourced platform community and be able to inference compatibility for new parts/products based on their tagged attributes, what type of part they are etc. What would be the best form of AI to tackle this? I was thinking a Expert System, but explicitly engineering all of the knowledge rules would be daunting because of the complex relations between literally tens of thousands of parts, hundreds of part types and many manufacturers. Would a ANN (neural network) be ideal to learn from the many inputs/decisions of the crowdsource platform users? Any help/input is much appreciated.


How to better integrate a unix development environment into Windows

I'm mostly a Windows user but I do most of my development (essentially web development) using unix tools and software. I've been going back and forth between using a dedicated lubuntu virtual machine on Virtualbox and using some tools directly in windows (msgit, python, django), but none of these approaches is entirely satisfactory. I'd like to hear of ways other devs use to better integrate a unix workflow into windows. For instance tighter integration between a linux and vm and windows. The vagrant demo showed how a VM could work off of a windows project folder and I found that nice. I'd like to hear of other tools and tips that would help mimic the workflow one can find on OS X (of course I understand that it cannot be as tightly integrated on Windows as it doesn't have the same unix underpinnings). PS: I have tried cygwin as well EDIT for clarifications about What I find lacking (thanks to axblount for pointing that out) : unix tools like msys et al do not work as well as their native unic counterparts. Many scripts, installers require further configuration or do not work at all. For instance getting virtualenvwrapper to work is not very straightforward. virtualbox: ideally I would like to use windows software (photoshop, sublime text 2) seamlessly with linux. I mostly use a FTP client atm to move over files edited on the windows side which is a tedious process. **SUMMARY:** It seems there are no established solutions. As a temporary solution I will probably try to use the native versions of frameworks and libraries through the windows command line when possible and switch to a tool like vagrant for incompatible programs. **MORE INFO FROM REPLIES AND COMMENTS:** The case-sensitivy issue seems to work against windows as pointed out by @GlenPeterson


Why does the US government disallow dynamic languages for secure projects?

I know some people that are currently working on a project for the US military (low security level, non-combat human resources type data). An initial state of the project code was submitted to the military for review, and they ran the program through some sort of security analyzer tool. It returned a report of known security issues in the code and required changes that needed to be implemented before delivery of the final product. One of the items that needed to be resolved was removal of part of the project that was written in Ruby as it is a dynamic language. What is the background/reason for not allowing a dynamic language to be used in a secure setting? Is this the government being slow to adopt new technologies? Or do dynamic languages pose an additional security risk compared to static languages (ala C++ or Java)?