Should I implement functionality for an xml file+schema?

I am working on a script to get data from excel spreadsheets to a database. The data is from surveys conducted by our office where the data comes in with very little formatting. At the moment, the data is manipulated with a lot of copy and paste, then analysed 'by hand' (ie. someone clicks and drags in excel and does pivots and copy pastes into other software).This leads to messy file structures and missing or incorrect/incomprehensible data. enter the need for a database. I have got a solution working which will accept csv files. It will parse the data and insert it correctly as long as each column header is correct. But my superior is pushing me to accept xml files with an xsd schema so I can validate the data. My argument would be that whether or not I use xml, the user will have to save the original file as another file type and I can validate the data within my script based on column headers anyway. The counter argument is that if they decide to include a new data set (ie, new table layout) my script might break. Either way, if the data type is incorrect, the user will have to go back to the file and edit it before any solution will work. So the answer I'm looking for is whether or not I should bother to set up xml functionality. [note, I am using php to script as I am not familiar with vba and I'm on a student placement so I do not have enough time to learn a new language.] [ASIDE - am I taking the wring approach to this?]


Turning in code you developed in your company as homework assignments

I'm currently running a start-up with a buddy and I noticed that some of my university assignments could be finished by simply copying some code from some of the programs we've developed. Are there any legal troubles I could run into? Or is this just a bad idea in general(as it is starting to feel right now)? Sorry if this is in the wrong place I wasn't sure whether to place this here or in stackoverflow.


Procedure or Event Driven Language For Education

I am here to ask a question that has been asked **many times** before. What programming language should I learn to become a intelligent conceptual programmer? Many people agree, you do not have to learn any one programming language; you need to learn programming as a concept itself (Most of us can become semi proficient in a language under a few weeks). Would it be better to learn procedure or event driven languages for conceptual purposes? Why? Let me be even more precise with my question above on this. I have written lots of basic code and program examples. I feels I have a firm root on basic concepts and now am ready to try some more complicated task like programming a graphic rendering engine or compiler. From what I understand C/C++ should teach me more of the important principles that I may carry over to fields like electrical engineering.


Can I get a C++ Compiler to instantiate objects at compile time

I am writing some code that has a very large number of reasonably simple objects and I would like them the be created at compile time. I would think that a compiler would be able to do this, but I have not been able to figure out how. In _C_ I could do the the following:               #include <stdio.h>          typedef struct data_s {         int a;         int b;         char *c;     } info;          info list[] = {         1, 2, "a",         3, 4, "b",     };          main()     {        int i;        for (i = 0; i < sizeof(list)/sizeof(*list); i++) {          printf("%d %s\n", i, list[i].c);        }     }      Using #C++* each object has it constructor called rather than just being layed out in memory.               #include <iostream>     using std::cout;     using std::endl;          class Info {         const int a;         const int b;         const char *c;     public:         Info(const int, const int, const char *);         const int get_a() { return a; };         const int get_b() { return b; };         const char *get_c() const { return c; };     };          Info::Info(const int a, const int b, const char *c) : a(a), b(b), c(c) {};          Info list[] = {         Info(1, 2, "a"),         Info(3, 4, "b"),     };          main()     {         for (int i = 0; i < sizeof(list)/sizeof(*list); i++) {             cout << i << " " << list[i].get_c() << endl;         }     }      I just don't see what information is not available for the compiler to completely instantiate these objects at compile time, so I assume I am missing something.


Represent actions(verbs) in REST URI

I have a print operation to perform for my customer documents. I need the other standard operations to be performed as well, like add,update, delete. so, I have following:   * For creating new customer:   URI = /customer/{id}, type = POST, Methodname = CreateCustomer()   * For updating:   URI: /customer/{id}, type = PUT, method = UpdateCstomer()   * For Delete customer:   URI = /customer/{id}, type = DELETE, Methodname = DeleteCustomer()   * For View:   URI: /customer/{id}, type = GET, method = GetCustomer() Now, if I need to print a document for that customer, I need a print function. My URI may look like this: /customer/{id}, type = POST , method = PrintCustomer(). But I have used that URI and POST type for CreateCustomer. I wanted the URI to look like this: /customer/Print/{id}, type = POST , method = PrintCustomer(). But I cannot have "Print" verb in my URI. Whats the best way to do this? I thought about /customer/document/{id} as the URI... but I will run into the same issue. I would have the CRUD operations on the "document". So, again I run out of what I would used for "print". Please advise.


Materials on structural languages design?

There is plenty of material about designing software for object oriented programming. Do you know of any good materials for pure structural programming? I am working purely in C and while I can use some experiences from object oriented programming I found out, that I know few tricks about good structural design.


Why can't we capture the design of software more effectively?

As engineers, we all "design" artifacts (buildings, programs, circuits, molecules...). That's an activity (design-the-verb) that produces some kind of result (design-the-noun). I think we all agree that design-the-noun is a different entity than the artifact itself. A key activity in the software business (indeed, in any business where the resulting product artifact needs to be enhanced) is to understand the "design (the-noun)". Yet we seem, as a community, to be pretty much complete failures at recording it, as evidenced by the amount of effort people put into rediscovering facts about their code base. Ask somebody to show you the design of their code and see what you get. I think of a design for software as having:   * An explicit specification for what the software is supposed to do _and how well it does it_   * An explicit version of the code (this part is easy, everybody has it)   * An explanation for how each part of the code serves to achieve the specification (e.g, a relation between spec fragments and code fragments)   * A _rationale_ as to why the code is the way it is (e.g., why a particular choice rather than another) What is NOT a design is a particular perspective on the code. For example [not to pick specifically on] UML diagrams are not designs. Rather, they are properties you can derive from the code, or arguably, properties you wish you could derive from the code. But as a general rule, you can't derive the code from UML. Why is it that after 50+ years of building software, why don't we have regular ways to express this? (Feel free to contradict me with explicit examples!) Even if we do, most of the community seems so focused on getting "code" that design-the-noun gets lost anyway. (IMHO, until design becomes the purpose of engineering, with the artifact extracted from the design, we're not going to get around this). What have you seen as means for recording designs (in the sense I have described it)? Explicit references to papers would be good. Why do you think specific and general means have not been succesful? How can we change this? [I have my own ideas that flesh out the bulleted viewpoint above, but I'm interested in other people's answers... and its hard to implement my scheme [[and maybe that's the real problem :-]] ] EDIT 2011/1/3: One the answer-threads hints that "documentation" (presumably textual, in particular not-formal) might be adequate. I guess I should clarify that I don't believe this. CASE tools appeared on the scene starting in the 80s, but the early tools mostly just captured pixels for the diagrams of whatever you drew; while the tools were arguablly commercially successful, they really weren't very helpful. A key insight was, that if the additional "design" artifacts are not formally interpretable, you can't get any serious tool help. I believe the same insight applies to any long-term useful form of design capture: if it hasn't got a formal structure, it won't be of any real use. Text documents pretty much fail this test.


Purpose of NOP instruction and align statement in x86 assembly

It has been a year or so since I last took an assembly class. In that class, we were using MASM with the Irvine libraries to make it easier to program in. After we'd gone through most of the instructions, he said that the NOP instruction essentially did nothing and not to worry about using it. Anyway, it was about midterm and he has some example code that wouldn't run properly, so he told us to add a NOP instruction and it worked fine. I asked I'm after class why and what it actually did, and he said he didn't know. Anybody know?


Legally, can I re reuse code for different customers?

The company I work for develops custom factory automation applications for multiple customers. Even though each application is custom, they contain common code which is re-used across projects. One of the customers is now looking for the source code to their application, which has caused a major storm in the company. Management have decided that we can't give them the source to the shared components as they are used by other customers. I've been asked to modify the shared components 'enough' so as they aren't common. So my questions are: 1) Legally, should there be any problem with re-using common components for different customer? 2) If I really need to modify the common components, then how much is 'enough' ? (I know this sucks, but I either do this or hand in my notice). Oh yeah, and my company has no license in place with any of these customers.


Application design question regarding saving files

I am working on an application in C# and I am having some extreme difficulty solving this design issue. Basically the application allows users to create cook books. A user can click "new book" and the application will create a book with a given name. Now the user is allowed to add "recipes" to that book. The user can save the book at any time. They can load this book on other computers with the application. Only one book can be open at a time in the application. So if they user wants to create a new book or open a different book, the application will need to close the current book and then open the next book. My question is, what would be the best way to solve this problem?   * How would I check if a book is open?   * How would I have the application create the new book?   * How would I have the application "close and forget" the book that was closed, so that the only open book is the new one? What I was thinking is that I would have a CookBook class and a Recipe class. The CookBook class would hold the information pertaining to the new book that was created and it would hold a list of all the recipes in that CookBook. I am just having a hard time figuring out the best way to give the user the ability to create a new CookBook and close the current cook book so the user can create a new one. The CookBook class will have a function that wil write the contents of the CookBook and the recipes of the CookBook to a file. There will also be a function in CookBook that will populate the application's user interface based on the contents of a CookBook that is loaded/opened by the user.


Streaming data from a microcontroller to a server?

Edit *We have a heart monitor hooked up to to an msp430 with a roving networks wifi module. I would like to connect send some type of a datastream to a webserver so that someone could watch it offsite. I would like to have a datastreaming connection or something to the webserver because I was thinking it is more natural than trying to do a post request every .5 seconds. (I know this isn't super specific but this is the level I am at right now.) I'm trying to figure out how to stream data (not video or anything big) from a microcontroller to a webserver and forward it to an iOS app. My buddy has a wifi module for our MCU and he claims we just write UART and the wifi module broadcasts our UART signal. So I want to stream that data to a webserver (php). Is there any type of wifi protocol for sending a stream of data to the server? What is the protocol for establishing a datastream connection on the MCU end? What kind of server side code do I need to recieve the datastream?


Why don’t UI frameworks use generics?

One way of looking at type safety is that it adds automatic tests all over your code that stop some things breaking in some ways. One of the tools that helps this in .NET is generics. However, both WinForms and WPF are generics-free. There is no `ListBox<T>` control, for example, which could only show items of the specified type. Such controls invariably operate on `object` instead. Why are generics and not popular with UI framework developers?


Using Microsoft Office software as part of my web service backend?

What licensing issues arise if I install and use Microsoft Office software (in this case Visio) as part of my web service backend? My company's flagship piece of software can convert Microsoft Visio files for use in their environment, but of course requires a local install of Visio to decode the files. The system I'm to create is to offer a sort of web service where people can upload their Visio files, and then we can show off one of the benefits of buying our full price software. In order to do this I'd need an install of our software on the server, as well as Visio. What I'm a little concerned about is technically any visitor to the site is technically using Visio. I can't really find any other examples when searching online so any advice would be greatly appreciated!


Is it common to print out code on paper?

I like to keep my lines of code under 80 characters because:   * I don't have to do any horizontal scrolling;   * I know the line is probably too complicated if it exceeds this limit; and   * it prints out nicely on paper. Concerning the latter, I've met only a few who actually print out code to look at (I'm one of them). So how common is it to print out code?


Is there a correlation between the scale of the project and the strictness of the language?

Explaining the difference between strictness of languages and paradigms to a colleague of mine, I ended up asserting that:   * Tolerant languages, such as dynamic and interpreted languages, are used best for prototypes and small projects or medium-size web applications. When choosing elegant dynamic languages such as Python or JavaScript with Node.js, the benefits are:     1. Fast development,     2. Reduced boilerplate code,     3. Ability to attract young, creative programmers who flee _“corporate languages”_   like Java.   * Statically typed/compiled languages are best for applications which require higher strictness such as business-critical apps or apps for medium to large-size apps.     1. Well-known paradigms and patterns developed for decades,     2. Ease of static checking,     3. Ability to find many professional developers with decades of experience.   * Strict languages such as Haskell, Ada or techniques such as Code contracts in C# are better for systems which favor safety over flexibility (even if Haskell can be extremely flexible), such as life critical systems and systems which are expected to be extremely stable. The benefits are:     1. Ability to catch as many bugs as possible at compile time,     2. Ease of static checking,     3. Ease of formal proofs. However, by looking at the languages and technologies used for large-scale projects by large corporations, **it seems that my assertion is wrong**. For example, Python is successfully used for large systems such as YouTube or other Google applications which require an important amount of strictness. Is there still a correlation between the scale of the project and the strictness of the language/paradigm which should be used? Is there a third factor that I've forgotten to take in account? Where am I wrong?


Testing complex compositions

I have a rather large collection of classes which check and mutate a given data structure. They can be composed via the composition pattern into arbitrarily complex tree-like structures. The final product contains a lot of these composed structures. My question is now: How can I test those? Albeit it is easy to test every single unit of these compositions, it is rather expensive to test the whole compositions in the following sense:   * Testing the correct layout of the composition-tree results in a huge number of test cases   * Changes in the compositions result in a very laborious review of every single test case What is the general guideline here?


Should I return Collection or ImmutableCollection from a method?

When writing an API in Java, returning an immutable collection of some sort, I've got the option of returning `Collection` (or `List`, `Map`, etc) from the method, or guava's `ImmutableCollection` (or `ImmutableList`, `ImmutableMap`, etc):               private final ImmutableMap<> _immutableMap = ...          public Collection<T> getValues() {         return _immutableMap.values();     }      or               public ImmutableCollection<T> getValues() {         return _immutableMap.values();     }      Which is better? Setting the return value as `ImmutableCollection` constrains me to use that exact type forever more, so that I can't swap out `_immutableMap` for my own immutable type later on that returns, say, an immutable view of the values that isn`t an ImmutableCollection` (constructing one requires copying the values, and I can't subclass it to provide an immutable view of a mutable collection). But there is benefit to people calling the method to see the return value is actually immutable, and have the `add` and `remove` methods marked as deprecated, rather than trying to add or remove items and have it fail at runtime. Generally, I like to return the most-specific interface type from a method, so that I can change the underlying implementation later on if necessary without breaking contract. But there is benefit to callers returning an `ImmutableCollection`, at the cost of constraining future development of the method and causing future possible performance problems due to copying all the values into an `ImmutableCollection` rather than providing an immutable view.


Multitasking how to keep track of what you're doing

I'm in a long debugging task, I need to figure out where to hook up some extra functionality I need. It's cumbersome work, and I've been debugging 2 whole days, and I'm on my third, but I work in multiple projects, and I'm returning to this after almost a week, and it's been hard to get back to the point I left at, and remember what was all this about, and what conclusions had I already arrived at. How do you keep track of what you were doing/thinking in this kind of scenario where comments aren't actually the "right thing" to do? I do some comments in my testing code, plus some informative git/hg commit messages but that's kind of dirty.. written paper might be the answer...


Need to make a stock inventory application

I need to make an application for my dad to keep track of stock trading inventory. He trades shares for himself and for his clients and would like to keep the records, things like buy/sell price of shares, profits, loss, date etc etc for his shares and his client shares and would like various kind of reports/views. He uses windows. I want to provide a local html page where he will enter new information and this should go to a local database and from his html page, he can choose reports etc and the reports will be displayed on the webpage etc.. I am thinking of using struts (and windows,tomcat) and mysql to make this application. I know some stuff from college days, but would look into the tutorials to setup things and program. Does this selection of technology looks good enough or something more easier and equally good exist? **update:** This is what I have settled for: Used mysql/windows, navicat lite and populated database/tables, and wrote some procedures taking some inputs. Like one procedure takes date and stock name as input and gives you quantity you have of that stock by that date and profit/loss so far, effective buy price of each share of that stock. This is for individual basis usage..and it looks like this will suffice for now -- very very simple, but I could custom create tables,custom create queries/procedures..Dad gets "contract notes" from his broker containing his daily transactions and I could get these notes online, compile these of last 2-3 years into one table and so the thing is in working state..very primitive, but works for his requirements for now. and yes, made 2 accounts (one read-only priviledge account using which he will run his queries,procedures etc) and other root, which he will use when populating his tables say once or twice in 15 days.


Architectural considerations for a new black box program

I see an emerging trend in "cloud" computing to move work load to a third- party server and get charged pennies for amount of work done in this way. This could be anything from file hosting to user authentication. So I thought about this for a bit and thought, why can't these services be offered in a peer-to- peer way rather than the traditional client-server way. So my idea is to create (to the best of my abilities to describe it) a black box virtual machine. Some program which hosts a web service on that computer which allows any other computer with this software to ask it to perform calculation of any kind, with the condition that the same can be asked from the host, with no financial "cost" of any kind. Obviously, it would be a security risk without proper precautions, therefore the following must be observed:   1. This software has the power to refuse execution requests or halt execution at any time.   2. Parameters are passed which request certain access permissions, among which include but are not limited to:      * Memory usage - How many megabytes are going to be at the program's disposal.      * Disk usage - How much disk space can be consumed.      * Namespace - Context for this program, which determines if it'll have access to disk space written by other programs with this namespace.     * CPU usage - Maximum % of the CPU which can be used during idle moments and non-idle moments.   3. "Disk" access is a black box with root "/" which is simulated, hiding actual disk contents. When a program is executed, a folder is created with its name under "/prog/" and is given free reign to read and write in any folder (including folder of other programs, perhaps with a parameter which requests it explicitly). Only other programs under the same namespace can see each other, but a program can be under multiple namespaces.    4. Some sort of analysis framework which statistically determine if porting multi-threaded jobs to other black box virtual machines is convenient and if so, will automatically attempt it. However it won't ask any work from a computer with resource parameters higher than the resource parameters it itself provides other computers. Meaning, you only get what you give in short.   5. If no limits are placed on certain types of resources, some sort of fail safe to ensure that the stability of the computer is not put at risk.   6. Some sort of powerful module system which allows people to write programs to work with this system.       * These modules would have a friendly way to install themselves from installations on peer computers or alternatively a way to download and install itself from an internet site.      * These modules would have to follow the same guidelines as a program executed on this sytem. My question is, a) what if anything, exists already which does this to some extent and 2) what language, platform, operating system would you advise to build this program? I was leaning towards Java, since a virtual machine has complete access to how its programs are run, hence I would only have to rework how files are read/written to the file system, however nothing is written in stone. Any advice would be appreciated, even if it is advice which suggests this type of thing is not possible. Also, if anyone has a good name for this program, I'm all ears. :)


What is the Startup spirit?

I keep hearing from Net and people around me that Startups are the place where you get to learn a lot, and Also, I come across term 'Startup Spirit' . What is the Difference between working culture of a startup and a corporate . I would like for people to clarify in the programming context.


Can software performance monitoring/profiling be automated to a high degree, as in unit testing?

Unit testing consists of executable code which exercise a certain functionality and then assert some conditions. The results are either Pass or Fail.   * The objective is always to have all tests passed. Software performance profiling usually requires help from some automated test/profiling tool, but the results seem to always require human interpretation, because:   * There are no clear pass/fail objectives.   * There are many facets (dimensions) in software performance, and one needs to consider the overall performance profile (the full picture; no pun intended) in order to interpret the result and make a decision.   * There are many pitfalls in software profiling, such as results skewed by profiling overhead, unintended interactions between modules or operating system, test cases not representative of needs of customers. Now that unit testing has been heralded as a major breakthrough in promoting the credibility of software engineering, is it possible to find the next silver bullet for the software performance issues? **Clarification** on "automated to a high degree":   * What I mean is that unit tests that were written long time ago (and updated as the software is developed) will remain useful indefinitely. During the better part of the software's production lifetime, there is little to no need of modifying the unit tests unless there are big changes to functionality.   * On the other hand, performance testing seems to require adjustments and re-running continuously, even well into the production stage. **Related:**   * How is performance testing integrated into your product lifecycle?


What if(event) statement means in JavaScript?

I'm rather new to JavaScript and programming in general so I am pretty much only used to seeing if statements that have some kind of comparison operator like, `if (x < 10)` or `if(myBool)`. I have seen an `if` statement checking against an `event`, but I don't understand what or why the `event` is being checked like that. What's the semantic meaning behind that check or comparison? Here is the code in question:               if(event){         event.preventDefault();     }


Is performance engineering a different specialization from general software development?

A major objective of software development is to focus on delivery of features implemented in good quality code. **Knowledgeable developers are supposed to write software with good performance** to the extent of their understanding (that is, **in the software module** they are working on). For example, they should be able to use appropriate algorithms and data structures when implementing various parts of the system. In other words, the first implementation which they wrote to satisfy a unit test would have the good performance characteristic that the final product is supposed to have. **However, when the system is large and complex** , consisting of many components written by different people/teams and include multiple vendors, is it more productive for a company to separate the roles of performance engineering from software developers, so that software developers can focus on features and correctness that meet specification, and the performance engineer can focus on measuring and improving performance without affecting feature and correctness? Put simply, are there two different hats, requiring two different mind-sets? **Motivation:** From the answers I got from another question An alternative to requiring red in TDD: reverting code change?, it dawns on me that during the main software development time, meeting functional requirements is a **must-have** while software performance is a **nice-to-have**.   * Tests on functional requirements have deterministic outcomes, usually Pass/Fail, or Accept/Reject.   * Performance characteristics don't have a fixed Accept/Reject target, but do have a metric which can drive the performance-optimizing effort.   * Future changes in functional requirements may make it necessary to sacrifice/adjust certain performance objectives.    * Personally, I do agree that there should be a quick feedback cycle between feature implementation and software performance monitoring.    * In this question I'm arguing whether these two are separate specializations - although some people might be specialized in both. **Possible outcomes** When feature implementation and optimization are done by different developers:   1. They will go into conflicts and nothing gets done. (contributed by @quant_dev)   2. The resulting software has better performance.   3. The resulting software has poor performance. **Related:**   * What skills do you think a performance engineer should have?   * _(Will ask in a separate question soon.) Is it possible that software performance issues can arise from large software systems that cannot be forecast even by the very knowledgeable software developers? Will a dedicated performance engineer be able to solve it?_


Is it good practice to keep the main function separate in its own file?

Is it good practice to have a main.c file that just has the main function in it and no other functions so that all other functions can be interfaced? If there is no definitive rule, when is it good to do so and not to do so?


How is Scala scalable?

> **Possible Duplicate:**   >  Why is Scala more scalable than other languages? The Wikipedia page on Scala says: > The name Scala is a portmanteau of "scalable" and "language", signifying > that it is designed to grow with the demands of its users. I've also read that: > And that's Scala's dirty little secret. Scala is only scalable in the sense > that it runs on the reliable, high-performing JVM platform. and also that "languages don't scale, platforms scale." How does Scala grow with demands of its users? Isn't it true to say that Scala "actually is scalable"? And as per line just above, isn't every language scalable?


Can you Improve your programming skills by learning other language paradigms?

If so, can you tell me how learning a new paradigm changed your approach for solving programming problems even if the problem is in another paradigm/language/technology? I will really appreciated If you can tell me in a specific manner, how your X (ie: JAVA/C#/C++) programming skills improved by learning Y (ie: Scheme/Prolog/Lisp). Also, what paradigms do you suggest helps the most to become a good programmer? My experiences are only structured - OOP, imperative - procedural, and into some extent template meta-programming, but my goal is not to learn another language, but rather to learn different approaches for solving problems. Thanks!


How often are comments used in XML documents?

I'm currently developing a web-based XML managing program for a client (though I may 'market' it for future clients). Currently, it reads an XML document, converts it into manageable Javascript objects, and ultimately spits out indented, easy to read XML code. **Edit:** The program would be used by clients that don't feel like learning XML to add items or tags, but I (or another XML developer) may use the raw data for quick changes without using an editor. I feel like fundamentally, its ready for release, but I'm wondering if I should go the extra mile and allow support for remembering (and perhaps making) comments before generating the resulting XML. Considering that these XML files will probably never be read without a program interpreting it, should I really bother adding support for comments? I'll probably be the only one looking at raw files, and I usually don't use comments for XML anyway. So, are comments common/important in most XML documents?


Learning programming, suggestions for a roadmap

Some background first: I am new to programming and have discovered it rather late in life; Like many hobbyists, my introduction to the subject has been through PHP/jQuery (yes, I know the popular mood around here... they-are-not- real-programminng-languages ;-) ). I like to believe that I am reasonably competent at what I do in my other life and this developing addiction to coding has taken a **very** heavy toll on my professional prospects. This is the question:   * What programming languages next? (No plans to ditch PHP in the immediate future, that will involve rewriting much of my code.)   * Any absolutely essential books I must read?    * Is it necessary to join a college/university course?    * Do I need to ditch my other profession to continue serious learning? My goals are:   * Develop a solid understanding of the science and art of programming.    * Continue to work on my own web application. (Hands on learning suits me best.) I am something of a generalist interested in everything from UI to database performance.


Does objective-c's method overhead make a 'many small methods' design approach inadvisable?

I generally favour using small methods, as recommended by, amongst others, Bob Martin in _Clean Code_. I've also read enough about Objective-C's internals to have at least some idea about how its message dispatch works (bbums series is particularly informative on this). Premature optimisation concerns notwithstanding, I'd like to know if all that work that Objective-c does with objc_msgSend is, in practical terms, significant enough for the 'many small methods' approach to be inadvisable for Objective-C projects. Empirical findings are particularly welcome (maybe I'll set up a test myself sometime). Experience from anyone who has written large objective-c projects would also be great. _Clarification_ The general tone of the question is intentional. I'm not asking about performance tuning of specific apps (which is why I ask here rather than on SO), but more about whether Objective-C's language characteristics discourage a certain design approach. I have observed that much of the code I've seen from Apple, and other parties (on github etc) tends towards large methods (and classes), and I'm wondering if this is a bias that has crept in because of the language itself. Of course I may have been reading the wrong code, or it may be cultural rather than technical factors that have led to the tendency if it exists. (For what it's worth, I am currently writing Objective-C, and I'm using small methods) _Further request_ I agree with both the answers that have been given. One further thing I'd like is for someone to point me to a (hopefully substantial) open-source (or otherwise visible) Objective-C codebase that uses nice short methods (and small classes). I haven't seen anything in Objective-C yet to compare with (for example) the fitnesse source.


How to make money from a small opensource utility?

I've got an idea for a tiny utility program that seemingly nobody has thought of before. I've no idea what the demand for it would be, but I'm certain that it would be 0 if you had to pay for it. And I like opensource. :) That said, it'd still be nice to get a few euros for my effort. How can this be done? My first idea was to put some non-intrusive adverts in the program (somewhere in the side), but I can't find any advertising programs that would allow you to put adverts in Win32 applications. Google AdSense certainly forbids it. Of course, a "Donate" button is always useful, and I think I will make one, but I doubt that many people will want to donate anything anyway. Any other ideas?


What is a good environment for learning like?

I have a feeling that lately I haven't improved much as a programmer. I may have learned a few bits regarding some technologies and acquired some domain knowledge, but it isn't much. In general programming skills there has been very little that I have learned. I haven't gotten better at reading legacy code. I still struggle with it. My design skills have not improved. I have hard time making design decisions. I have a limited experience of different workplaces and so I'm asking that how much does the working environment affect ones learning and what things in it specifically? I guess there are things that affect ones motivation to learn, but also things that make it possible to learn. Please share your experiences.


Can we assume that all users today have Internet access?

As the Internet is pretty much ubiquitous, can we as developers assume that all users have Internet access? Now I don't mean that the code is written in such a way that if there is no connection then the whole program crashes due to lack of error code. What I mean is, can programs today be developed under the assumption that its users will always have access to the Internet? You may ask "What do we gain by assuming that?" The reason why I'm asking is because at uni we use quite a few programs which require Internet access due to the way it checks the licenses (it checks your IP address -- if it's not an address at campus, then you you're not allowed to use it). Note that the program itself should work fine without Internet access; it's just needed for license checking. **EDIT:** I'm talking about desktop applications here. **EDIT2:** From some of the answers I get a feeling of being accused of exploiting the users in unethical ways. I'm _not_ endorsing what I've described in this question -- I'm just asking about it because the developers of some of the programs we use at uni have done this. Personally I think doing this is plain out stupid and wrong.


What are the differences between a programmer and a webmaster?

I thought they were 'the same' but now I realize they are not (two different sites in stackexchange). However I don't know the differences, what does a webmaster do (and don't) and the same for a programmer (or coder or developer?)


How to handle encryption key conflicts when synchronizing data?

Assume that there is data that gets synchronized between several devices. The data is protected with a symmetric encryption algorithm and a key. The key is stored on each device and encrypted with a password. When a user changes the password only the key gets re-encrypted. Under normal circumstances, when there is a good network connection to other peers, the current key gets synchronized and all data on the new device gets encrypted with the same key. But how to handle situations where a new device doesn’t have a network connection and e.g. creates its own new, but incompatible key? How to keep the usability as high as possible under such circumstances?   1. The application could detect that there is no network and hence refuse to start. That’s very bad usability in my opinion, because the application isn’t functional at all in this case. I don’t consider this a solution.   2. The application could ignore the missing network connection and create a new key. But what to do when the application gains a network connection? There will be several incompatible keys and some parts of the underlying data could only be encrypted with one key and other parts with another key.   3. The situation would get worse if there would be more keys than just two and the application would’ve to ask every time for a password when another object that should get decrypted with another key would be needed.   4. It is very messy and time consuming to try to re-encrypt all data that is encrypted with another key with a _main_ key. What should be the main key at all in this case? The oldest key? The key with the most encrypted objects? What if the key got synchronized but not all objects that got encrypted with this particular key? How should the user know for which particular password the application asks and why it takes probably very long to re-encrypt the data? It’s very hard to describe encryption “issues” to users. So far I didn’t find an acceptable solution, nor some kind of generic strategy. Do you have some hints about a concrete strategy or some books / papers that describe synchronization of symmetrically encrypted data with keys that could cause conflicts?


In Java, why were protected members made accessible to classes of the same package?

From the official documentation...               Modifier    Class   Package Subclass    World      public      Y       Y       Y           Y      protected   Y       Y       Y           N      no modifier Y       Y       N           N      private     Y       N       N           N       The thing is, I can't remember having a use case where I needed to access protected members from a class within the same package. What were the reasons behind this implementation? **Edit:** To clarify, I'm looking for a specific use case where both a subclass and a class within the same package needs to access a protected field or method.               package some.package;     public class A {      protected void protectedMethod(){       // do something      }     }          package another.package;     public class B extends A{      public void someMethod(){       // accessible because B is a subclass of A       protectedMethod();      }     }           package some.package;     public class C {      public void anotherMethod(){       // accessible because C is in the same package as A       protectedMehtod();      }     }


Interception vs Injection: a framework architecture decision

There's this framework that I'm helping to design. There are some common tasks that should be done using some common components : Logging, Caching and raising events in particular. I am not sure if it's better to use dependency injection and introduce all of these components to each service (as properties for example) or should I have some kind of meta data placed over each method of my services and use interception to do these common tasks? Here's an example of both: **Injection:**               public class MyService     {          public ILoggingService Logger{get;set;}          public IEventBroker EventBroker{get;set;}          public ICacheService Cache{get;set;}          public void DoSomething()     {     Logger.Log(myMessage);     EventBroker.Publish<EventType>();     Cache.Add(myObject);     }          }      and here's the other version: **Interception:**               public class MyService     {          [Log("My message")]     [PublishEvent(typeof(EventType))]          public void DoSomething()     {          }     }      Here are my questions:   1. Which solution is best for a complicated framework?    2. If interception   wins, what are my options to interact with internal values of a method (to use with cache service for example?)? can I use other ways rather than attributes to implement this behavior?   3. Or maybe there can be other solutions to solve the problem?


comparison of an unsigned variable to 0

When I execute the following loop :                unsigned m;      for( m = 10; m >= 0; --m ){             printf("%d\n",m);         }      the loop doesn't stop at m==0, it keeps executing interminably, so I thought that reason was that an unsigned cannot be compared to 0. But when I did the following test                 unsigned m=9;     if(m >= 0)         printf("m is positive\n");     else         printf("m is negative\n");      I got this result:               m is positive       which means that the unsigned variable m was successfully compared to 0.   Why doesn't the comparison of m to 0 work in the for loop and works fine elsewhere?


Should I use nested matrices or dictionaries?

As per Should I ask my question about which data structure to use here? I'm asking this here. Hopefully this isn't too implementation specific. I'm currently developing a program that will represent chemical structures (and eventually allow manipulations/reactions of them). I've hashed out two different systems of storing this data but I'm not sure how to pick which one. # Option 1: Nested matrices Chemicals have (more or less) definite structures and relative positions of items, and it seems as though it would be easier to represent something like that with a matrix - then I can assign definite 'coordinates' to each atom or bond. Unfortunately, you end up with some overlap if you have a structure that branches out a fair bit. To solve this I ended up working out a solution that used nested, 5x5 matrices.               [[None,  None, [CH3], None, None ],      [None,  None, Bond,  None, None ],      [[CH3], Bond, C,     Bond, [CH3]],      [None,  None, Bond,  None, None ],      [None,  None, [CH3], None, None ]]      Here `C` represents the element carbon (this could be represented a couple different ways, and isn't particularly relevant here). `Bond` represents a bond, and `[CH3]` represents another 5x5 matrix. This is the uppermost (`[0][2]`) `CH3`               [[None, None, H,    None, None],      [None, None, Bond, None, None],      [H,    Bond, C,    Bond, H   ],      [None, None, Bond, None, None],      [None, None, Root, None, None]]      Here the lowermost `Bond` is a reference to the same object as the uppermost `Bond` in the first structure, while `Root` is (some undetermined) way of relating that this is where the matrix connects to the next level up. If this were a more complex structure, one of the `H`s would be replaced by another matrix, such as an additional `[CH3]`. **Advantages of this method:**   * Everything is explicitly laid out, including structure, which is good according to The Zen of Python.   * When these chemicals are (eventually) represented graphically it will (theoretically) be much easier to make sure everything is in its place  **Disadvantages:**   * This isn't readable at all if you have a more complex structure   * This is nested, not flat   * This is going to require a lot of recursion to walk through # Option 2: Dictionaries Another way I could represent these with significantly less nesting and better readability would be using dictionaries. Each molecule would be a key in a dictionary `{Molecule1 : Data, Molecule2 : Data}` and the data would be dictionaries as well `Atoms: Data, Bonds: Data`. This requires quite a bit less nesting, but would require a little more work when I eventually want to display them. # Closing thoughts Before asking this question, and indeed while writing it, I've been pretty set on dictionaries. It seems like a cleaner and easier method of storing this data, and won't require figuring out a really nasty recursive technique to walk through a molecule. However I wouldn't be surprised if I missed something which is why I'm asking here. If this seems too implementation specific please let me know what you think I should change and I'll do my best to make it more general


How can I set a time limit for a game?

I am learning the multi-threading and timer in C# now. But it seems I can't find a good solution. For example, I would like to see how many addition problems that I can solve within 1 min. I would like my program to have   1. A digital clock to count for 60 seconds in the top of my Console.   2. Print a math problem in the middle of my console wait for my input.   3. When 60 seconds is done, stop the math problem challenges immediately (most of time, it is still waiting for my input, but we will stop it immediately).   4. Count how many correct problems that I have solved. Two challenges of the program now.   a) how can we make sure the print time and math problem do not mess up.   b) how can we stop the math challenges part immediately after time is up


What are the most important OO skills to show off in the job hunt?

I am in the market for new employment, and found a position were they asked me to create a programming sample based off an assignment. I blew the sample trying to get it done quickly one night, and got declined - only to be given a second chance recently. The concern was that I didn't really demonstrate object oriented knowledge. I've rethought my approach but I figure it's worth asking: if you were hiring someone for an OO position, what skills would you most want to see them demonstrate they had a firm grasp on? I want to be sure that I'm missing anything important this time around.


How difficult would it be to migrate a Struts/JSP application to Groovy?

I have taken over development of a JSP/Struts application. Right now it's a bit of a mess, and I'm finding the JSP pages with Struts tags to be insanely verbose. Has anyone migrated a Struts application to Groovy/Grails? Can it be done incrementally, page by page? @4bu3li: I was thinking of replacing the JSPs one by one with Groovy HTML builder code. IMO struts tags are a masterpiece of verbosity and obfuscation, and I'm tired of matching open and close tags. Right now the team is just me and one other guy, and I know Groovy better than I know JSPs and Struts. We are reworking the entire site, so it's all going to be rewritten somehow. But I can't stop maintenance, so I need to incrementally rewrite it page by page. Could I just start reworking Struts action methods to return Groovy-generated content?


Are my team's processes out of control?

I'm a software dev team leader (I recently took control of a new team), and ultimately responsible for maintaining high productivity, good quality and organized priorities. I have 6 senior developers in my team, but things feel like a mess here. The situation is that I have to deal with JIRA requests from about 10 different points of contact in our company, and they all represent different business units, or clients. The problem I have is that my job mainly consists of putting out fires the whole day and making sure that everyone's problems are being worked on. Unfortunately, the culture in our company has been high productivity (fast releases) but low quality (production bugs), and our clients won't accept a sudden delay in results. What are some good ways of handling this? I have tons of theories, but I'm looking for an answer from someone who actually has working experience in a situation like mine. Here is a small list of how things work:   * Each developer is responsible for a specific application and services interacting with it;   * Releases are typically tested by the client in a simulated production server, and then deployed to the live server;   * Each application is used by an average of 50-80 people, with 8 applications in total. Thanks


Coming up with a version control strategy for SVN

Off the clock I'm going to try and come up with a strategy for version control for my company; we currently use SVN but there's no structure to it - we basically only have a trunk and only commit to that. Recently the development manager started a second repository that acts as our "tag", but it has to be manually merged with the "trunk" since it's not part of the same repository but a totally separate one. In effect there is just one folder, called "Dev" (there's actually different "Dev" folders at different dates but just "Dev" is the main one) and under that is everything else; all the other projects. It's not organized by project at all, it has no concept of branches/tag/trunk or anything. The person who set it up initially (long gone, of course) seemed to not know how to set SVN up at all, and since then nobody has bothered to learn how to do things properly for fear of breaking something. We don't use any kind of CI (or automated testing, unfortunately). First, should we have it separated by project? For instance, we have: Two ASP.NET web sites (not Web Applications, Web Sites), a Web Service, a deployment folder for all the table scripts and stored procedures, two command-line clients for external projects that get called by the WebSites and a shared folder that has common business objects and the like. Should each of these be their own project with a branches/tag/trunk setup, or should it be like this:               dev/       branches/       tags/       trunk/           Site1/           Site2/           WebService/           SharedCode/      and have all the branches and everything have a copy of the entire Dev folder? That approach might be easier to swallow since we often have situations where we need to make changes in the shared code library and at least one (usually both) of the web sites as well. Second, we do regular releases ("pushes" in our parlance) to our dev server and live server. From what I've read the best way to handle this would be that all development goes into trunk/, branches are "temporary" and used for adding a new feature that might affect trunk, and tags are for releases? So, we push every month let's say, and I'm working on a brand new module. I would branch trunk, and use that branch for my code, writing and testing it and whatever. When the module is done, I'd merge it back into trunk (and maybe delete the branch), and when we are ready to deploy we would tag it ("May2011" let's say). If we have a bug fix after it goes live, it would be fixed in the May2011 tag and merged into trunk (so trunk gets the fix as well), and then May2011 would be pushed out again with the fix? Is this the intention of tagging?


How quickly should I adopt new technology, i.e. new .NET versions, new VS versions, etc.?

I'm never sure how quickly I should be adopting new technology. I often just don't until there is a need from a client, or I have a new project that makes it easy to just start with a new version. How often do others adopt new technology? Is there a reason to jump right in? Is there a good reason not to? Are there some good rules of thumb, or guidelines? Approaches?


Algorithm to generate N random numbers between A and B which sum up to X

This problem seemed like something which should be solvable with but a few lines of code. Unfortunately, once I actually started to write the thing, I've realized it's not as simple as it sounds. What I need is a set of X random numbers, each of which is between A and B and they all add up to X. The exact variables for the problem I'm facing seem to be even simpler: I need 5 numbers, between -1 and 1 (note: these are rational (floating point) numbers), which add up to 1. My initial "few lines of code, should be easy" approach was to randomize 4 numbers between -1 and 1 (which is simple enough), and then make the last one `1-(sum of previous numbers)`. This quickly proved wrong, as the last number could just as well be larger than 1 or smaller than -1. What would be the best way to approach this problem? PS. Just for reference: I'm using C#, but I don't think it matters. I'm actually having trouble creating a good enough solution for the problem in my head. * * * I also wanted to provide my current solution to the problem, _but do remember that it's quite imperfect and it was created as a quick fix to the initial problem_!   * Generate 4 random numbers between -1 and 1   * Create a "final" number `X=SUM(previousNumbers)`   * If the final number is >1 or <-1, then:      * Get the "amount" over 1 / under -1 and make the last number a 1 / -1     * Find another number which can accept this amount and still inside the brackets     * If no number can take the amount (it's too large / too small) then divide the amount in half and try again for each half   * Randomize the order of the generated numbers and return them This works in the sense that this algorithm generates 5 numbers which are between -1 and 1 and their sum is 1. However the downside is that quite often one of the generated numbers is a 1 (or -1), which doesn't feel very random.


Which is better API: table.add_row() or table.rows.add()?

I'm writing a library to create and manipulate Word .docx files in Python. In general, I take a lot of influence from the Microsoft VBA/C# API for Word in designing the API, figuring they've given it a lot more thought than I'll ever be able to. Several times I've found the wisdom in designing it the way they did only after getting much further down the road. A table has the properties `.rows` and `.columns`, each of which is a sequence of the `Row` and `Column` instances in the table, respectively. In the MS API, the methods for adding a new one are `Table.rows.add()` and `Table.columns.add()`. I'm inclined to believe this is more complicated than necessary, making my API harder for beginners to learn without really providing any benefit. I'm thinking `Table.add_row()` and `Table.add_column()` would better suit. As it happens, it also simplifies the code somewhat; that's not a motivator, just an observation that I wonder might be trying to tell me something. Is there an argument for preferring the former?


Considerations for developing a large scale system that needs to be both traditional web accessible and mobile accessible

I am trying to begin planning of a system that would be both client management, and document management, with tools built in to do analysis on all of the transactions, etc. I'm wondering what are the considerations I need to be mindful of at the beginning stages so that when I need to scale up I haven't shot myself in the foot in the beginning. I also need to make sure that it is mobile accessible and not just traditional web accessible. I've never done a large scale system like this and I have ample time to plan so any suggestions are much appreciated. **Edit** I also need to make sure that the handling of data would be secure because it would be sensitive client data.


How to design database having multiple interrelated entities

I am designing a new system which is more of a help system for core applications in banks or healthcare sector. Given the nature of the system this is not a heavy transaction oriented system but more of read intensive. Now within this application I have multiple entities which are related to each other. For e.g. Assume the following entities in the system   1. User   2. Training   3. Regulations Now each of these entities have M:N Relationship with each other. Assuming the usage of a standard RDBMS, the design may involve many relationship tables each containing the relationships one other entity ("User_Training", "User_Regulations", "Training_Regulations"). This design is limiting since I have more than 3 entities in the system and maintaining the relationship graph is difficult this way. The most frequently used operation is "given an entity get me all the related entities" . I need to design the database where this operation is relatively inexpensive. What are the different recommendations for modelling this kind of database.


Why isn't it possible to switch between header and cpp in Visual Studio?

For the last eight years I wait for Microsoft to add the basic C++ functionality of switching back and forth between .h and .cpp files, and it keeps astonishing me it is still not supported in Visual Studio 2010. Does anyone know why they refuse to add this essential feature?


Developer survey of code quality

I know it's almost impossible to define and/or measure code quality. Instead of trying to measure it I would like to survey the other developers to see how they _perceive_ the current quality of the code. I would like to stress that I want each developers opinion of the code, not a statistical measure of it. I'm thinking of asking them to rate the code in a few categories like maintainability, consistency, and stability. In addition I'd like to ask them what they think is going well and what they think needs the most improvement. Is this an effective way to get a perception of the code base from the other developers? Am I asking the correct questions? Will this provide useful information or is a useless exercise?


Which programming language for text editing?

I need a programming language for text editing and processing (replace, formatting, regular expressions, string comparison, word processing, text analysis, etc.). Which programming language is more powerful and has more functions for this purpose? Since I work PHP for my web projects, I currently use PHP, but the fact is that PHP is a scripting language for web applications; my current project is offline. I am curious if other programming languages such as Perl, Python, C, C++, Java, etc. have more functionality for this purpose, and worth of shifting the project?


Recommendable reads about programming history?

As much as I love to code, as little do I know about the history of programming. I know some names (Turing, Ritchie, Linus) - but that's it. I know roughly what they did and I'm a bit ashamed. This, and because I want to know more, I'm asking for recommendable reads (be it books, e-books, articles, w/e) on this topic.


How to make money by making JavaScript libraries?

There are lots of JavaScript libraries. Why people create them, if it's not for money? If it is, how do they make money on something anybody can copy, since the code source is available publicly?


Why don't xUnit frameworks allow tests to run in parallel?

Do you know of any xUnit framework that allows to run tests in parallel, to make use of multiple cores in today's machine? If none (or so few) of them does it, maybe there is a reason... Is it that tests are usually so quick that people simply don't feel the need to paralellize them? Is there something deeper that precludes distributing (at least some of) the tests over multiple threads?


What's the difference between an API and an SDK?

I was looking through various APIs and SDKs, when I realized that I couldn't really tell the difference between something called an API and something called an SDK. Both of them are, conceptually, a way for your program to interface with and control the resources provided by another piece of software, whether that other software is a web service, an end-user app, an OS service or daemon, or a kernel device driver. So, what is the semantic difference between an SDK and an API?


Faq and Best tips Regarding Learning Database?

For a programmer with no prior exposure to databases   1. What would be a good database to learn Oracle vs SQLserver vs MySQLvs PostgreSQL?   2. I have come across lot of discussion MySQL and PostgreSQL and frankly I am confused on which to start with. Are these very different, in the sense if one had to switch, would the exposure to one be counter-productive to learning the other?   3. Is working with databases heavily platform dependent?   4. **What exactly do people mean by Data base programming vs. administration?**   5. Do people chose databases based on the programming language used for the application developed?   6. In general, Working with databases is it implicit that we work with some server?    7. Does the choice of databases differ when it comes to game development? If so what factors does it differ by?    8. What are the Best Tips that you have found to be useful when learning databases  Edit: Some FAQ i had and found the same on SO   1. What should every developer know about databases?   2. Which database if learning from scratch in 2010?   3. For a beginner, is there much difference between MySQL and PostgreSQL   4. What RDBMS should I learn/use? (MySql/SQL Server/Oracle etc.)   5. To what extent should a developer learn database?   6. How are database programmers different from other programmers?   7. what kind of database are used in games?


Performance issues when parsing code

I was wondering about performance issues when parsing a source file that is being edited by the user (for example, when you need to give a syntax highlight).   I think that the simplest approach is to parse every time the code changes, get the results, and replace the current code with the highlighted one. With large files this may be a problem though. Is there a better way to do that? I suppose a solution may be to parse just the "area" where there was the last edit. Is this a good idea?


Using a TFS Build Process Template (Workflow) for Deployment

I'm thinking of using TFS Build workflows for complex deployments. We have some that may need to deploy:   1. Web applications and services   2. Database   3. SSRS Reports   4. SSIS Packages   5. Who knows what else I like the fact that I can give the workflow some basic parameters like which build to deploy and it would just run. Potentially, some parts might need human approval, and I know that workflow can handle that too. An example is that we might use the workflow to create a change script from our Visual Studio Database Projects, but the DBA group will want to approve the script before it is run. I'm interested to know whether others have used "builds" for this in the past, and what problems were found.


Approach to managing multiple services like Evernote, Google drive, dropbox in iOS

I'm trying to think up a scenario when I'd have three different forms of NSData (or whatever) to be sent to three different services like Evernote, Google drive, Dropbox. Granted, each of those has there own SDKs to be bundled into the iOS app, and thats okay. Now, I want to create a single Class that serialises the both sending and receiving data to and from the above services. My mind is taking me to a `singleton`, a shared class with `NSOperationQueue` at its foundation. I'd periodically add `{send:"this data" to:dropbox}` into an `NSOperationBlock` and add it to the `singleton`. At any given time say the following operations could be within the `singleton`'s `NSOperationQueue`.   * `{send:"this data" to:dropbox}`   * `{send:"this number" to:evernote}`   * `{send:"this dude" to:googledrive}` The `singleton` would need to handle internet reachability, app sessions etc. This class would be connected to **Dropbox** , **Evernote** and **GDrive** and their respective SDK bundles. So, in reality the only thing this class would do is, hand over the data to the respective SDKs to handle it on their own (which is like saying, handle it and let me know if it was a success or failed.) I'd really like suggestions/critique on the approach i'm taking. I have little experience with `NSOperationQueue`, I don't know if I'm making the right choices here. Some clues to a good API pattern would really be helpful. ## UPDATE It was suggested I create a wrapper for each service. But If can stress that theres little to do in a `Dropbox Wrapper` classes, Since in iOS everything is handled in their own SDK. For example, **Evernote** extends only a simple `[ENSession .. uploadNote..]`. All I wanted to do, is serialise my uploads into a single global queue and then dispatch the single methods to either `Dropbox` or `Evernote` or wherever. If suppose there is a service that requires some form of data handling, I'd then use a _wrapper_ and dispatch its own thread. I'll add this into the question too. Its the serialising & queueing I want.Sounds reasonable?


Open/Closed principle and reopening Ruby Classes

In OOP there is the Open/Closed principle that states that > "software entities (classes, modules, functions, etc.) should be open for > extension, but closed for modification". Taking in consideration that in Ruby it is to possible to reopen a class, don't you think that this breaks the Open/Closed principle? When do you think we should favor reopening classes instead of just extending them? What do you think that are pitfalls in reopening classes?


I want to build a java client library, where do I start?

I'm in my second java course at school and am thinking of developing a web service client library for one of my projects. I'd like the library to be able to query the MusicBrainz web service and have it return a data object or search results depending on the query. Does anyone have any advice or a reference that I can be pointed to? Specifically, I'm looking for advice on how to structure my code (e.g. how do I break up my classes) as well as help understanding how communication should flow from some external app, my library, the web service, and back. There is an existing MB java client library, but I am trying my hardest not to go rummaging through it. I want to have the satisfaction of building my client from scratch and not just copy/pasting code and ideas from the existing app. **Edit:** Just to be clear, I'm not saying that I want to avoid looking at other libraries. What I meant above is that I know that there is already a library that does what I'm looking for, but since I'm fairly new at this stuff I want to avoid the temptation of just blindly copying ideas when I get stuck or when I'm not sure which direction to go in. Having multiple references would hopefully put me in a better position to know what to do. What I'm looking for is some kind of reference guide I can use to build my own library. I haven't found much on my own so I thought posting a question on here might give me a few ideas or some new things to check out.


NodeJS: Freeze dependences before testing and deployment? Check in node_modules?

Suppose you have a NodeJS application. A release could consists of multiple steps:   1. Automated and/or manual tests   2. Deployment   3. (if something goes wrong) Rollback to the last stable version There are some desirable requirements regarding the application's dependencies:   * When you have done your testing, you want to deploy _exactly_ the version that you tested with, including all dependencies.   * The same goes for rollbacks: You want to restore not only your own code, but all external dependencies, too. My question is about best practices to meet this goals. **What is the recommended way to create a snapshot of all dependencies of your NodeJS application?** Here are three options that I can think of:   1. In this article, the author recommends to put the `node_modules` directory under source control. (Not for all modules, but only for modules that will be deployed.)   2. One alternative, which the same article describes as an anti-pattern, is to use explicit version locking. His argument seems reasonable: When you lock, for example, Express to a certain version, you still cannot control that one of its dependences hasn't introduced a subtile bug, later.   3. Just don't care and always use the most recent version of all external modules. * * * My thoughts so far (but I don't have much experience with NodeJS yet):   * 3) seems to be too reckless.   * I tend to 1), but I'm not sure where to put the `node_modules`. When you just check it along with your normal code, I fear that workflows like `npm link` to your local modules will no longer work. Additionally, there is always the problem of annoying merge conflicts.


How to do best practice development as the single IT guy in a small company

For the best part of the last decade I have been working as the only IT guy in tiny company. At it's peak this company employed about 8 staff. It's now down to 4, one of them part time. So the going is tough - but given its size it always has been. I enjoy working with the people there which is why I am still there and my employees have never blamed me for poor code or anything. They are entirely supportive of my work. However I struggle intensely with the whole "do it properly" idea. For the first 6 years of working there I largely worked on our in-house web based CMS. This is from just before the times of Ruby On Rails setting the tone as an example of an efficient web application stack or Wordpress setting the blogging standard. At the time we surveyed the available options and decided that nothing offered what we wanted with respect to standards, accessibility and usability (big mistake in hindsight, but such is life). So we (read I) set out developing our own CMS. The code I churned out is just awful, awful stuff. It got written in a haste as we were always playing catch-up with features or hastily meeting client deadlines. Our system became slower and unpredictable, changes difficult and so on. As you'd expect really. I got more and more frustrated as I am aware of TDD, refactoring and so on, but there just never seemed to be the time. Also note that being the only IT guy also means maintaining the office network, providing desktop support, technical support in writing proposals and last but not least maintaining our servers and the 50-60 websites that run on them using our CMS. I've rarely felt confident to even approach TDD as it IS a lot slower in the first instance. This has been constant source of real, and I really mean REAL, deep frustration. I know I am doing it the wrong way, but there appears to be no chance to do it the right way. Maybe I am just too weak, not a risk taker. I don't know. But how have others coped in such a situation? I am frequently at the point of throwing in the towel. Probably would have done if there weren't the tiny issue of having to support a family. Moving jobs would be difficult as it will likely mean moving countries (but that's by the by). I sometimes wonder whether this whole TDD stuff is something which is almost the exception rather than the norm. We've recentlty jumped ship to Wordpress as we will never be able to get to that quality with just one IT guy. Having peaked into the code base, Wordpress doesn't look much clearer than what I coded up, and lets not talk about many of the plugins. But it doesn't seem to matter because Wordpress as a platform is rock solid, well documented and obviously has an outstannding QA procedure. And since moving to Wordpress most of my work appears to be around integrating plugins and coding up a few lines to hook it all together. Not much development at all really. Which leaves me with even less opportunity to do real satisfactory agile development. I am particularly keen to hear from others in similar situation to me. Do you just write it off as part of the life of a developer in a tiny SME? I've really lost confidence in my ability to develop software as opposed to simply hack it all together. How do you go about doing best practice agile web development when you're the only guy on the team. EDIT: good answers so far. I'd like to hear from others who are or have been in similar situations. ie working as the sole IT guy in a very small company. How do you cope with the constant demands for your time with no-one else to realistically help you out? Thanks.


Are utility classes with nothing but static members an anti-pattern in C++?

The question Where should I put functions that are not related to a class has sparked some debate over whether it makes sense in C++ to combine utility functions in a class or just have them exist as free functions in a namespace. I come from a C# background where the latter option does not exist and thus naturally trend toward using static classes in the little C++ code I write. The highest voted answer on that question as well as several comments however say that free functions are to be preferred, even suggesting static classes were an anti-pattern. Why is that so in C++? At least on the surface, static methods on a class seem indistinguishable from free functions in a namespace. Why thus the preference for the latter? Would things be different, if the collection of utility functions needed some shared data, e.g. a cache one could store in a private static field?


Using Power of 2 numbers to represent types

Let's say that we have some values, represented by power of 2:               TYPE_1 = 1     TYPE_2 = 2     TYPE_3 = 4     TYPE_4 = 8     ...      I need to store some of these types in one value. Example: To represent `TYPE_1` with `TYPE_3`, the value is `5`. What operation is used to identify that value `5` represent `TYPE_1` with `TYPE_3`?


pcre case insensitivity: handle escape sequences as raw bytes?

Consider the following regex (no unicode):               Example:\x04\x05\x41      Suppose you search this regex case-insensitively. Would you expect it to search the final \x41 in case-sensitive manner? People whom I ask actually expect such behavior. And such expectations are wrong. Perldoc says: > Note that a character expressed as one of these escapes is considered a > character without special meaning by the regex engine, and will match "as > is". Which basically means that if the character escaped is printable non special character it's equivalent to just typing that character. And that's how it actually behaves. However if regex is case insensitive alphabetic characters do have a special meaning of "this character or same character in opposite case" and such special meaning is not ignored in \x sequences. Escape sequences have "raw byte" semantics, but not always. Does it seem to you like a design awkwardness? Is there a way to cause pcre to treat \x sequences as raw bytes that ignore case sensitivity? Perhaps as a flag? As non standard patch? If no how if at all pcre engine code can be modified to provide such functionality?


Do we need test data or can we rely on unit tests and manual testing?

We're currently working on a medium/large PHP/MySQL project. We're doing unit testing with PHPUnit & QUnit and we have two full time testers that are manually testing the application. Our test (mock) data is currently created with SQL scripts. We have problem with maintaining scripts for test data. The business logic is pretty complex and one "simple" change in the test data often produces several bugs in the application (which are not real bugs, just the product of invalid data). This has become big burden to the whole team because we are constantly creating and changing tables. I don't really see the point of maintaining the test data in the scripts because everything can be manually added in the application in about 5 minutes with the UI. Our PM disagrees and says that having project that we can’t deploy with test data is a bad practice. Should we abandon maintenance of the scripts with test data and just let the testers to test the application without data? What’s the best practice?


Mobile web development rudiments

How does one get started with web development for mobile devices (including phones)? I know some old good HTML & JS, but I'm wondering what the modern way is. To make it concrete, I need to implement a client for an enterprise app. Think of a login-protected dashboard for managers. Given that I only have basic knowledge and have never implemented such applications, what do I need to take into account when choosing platform and technology?   1. Shall I go for Android / iPhone, or HTML & JS, or HTML5? What are the general pros and cons that I need to consider?   2. How can I test an Android app on desktop without using a phone?    3. Same question about testing HTML/JS or HTML5 (the mobile version needs to be different from desktop, and I would like to see it exactly as if it was a phone).   4. What resources (preferably online) do you recommend for learning the rudiments? I mean especially HTML & JS: What does the site need to be like to work great on smartphones (and not only on desktops)? I mean possible UI glitches, limited support for some HTML/JS features, page size, and whatever other important details are there.


Zend Framework View Helper Composition

So I'm reviewing a piece of code that is a perfect candidate to be abstracted away into a view helper. However at the moment, the piece of code uses two other view helpers to get the final display. Now my question is, if a new view helper is created, is it recommended to inject the two helpers being used already, into the one created to get the final result needed? I've not seen anything for or against, my initial feelings were that the code probably needs refactoring, but I don't think the dev will be willing to, so what I have outlined seemed like a nice middle ground.


Learning embedded systems development without supervision

I have graduated this year and got my first job involved with C programming, Linux administration and embedded systems development. I feel quite content with my job, but I'm afraid I won't become a successful programmer in this field. I'm a lone developer on my job now, with my teammates being hardware experts, there is no one to guide me or teach me in the ways of embedded programming, I have to study all on my own. So here are my questions. Is it possible to become a good embedded systems developer starting from an entry level position without any supervision by senior programmers? How could I become one (perhaps with the help of forums, IRC channels, good textbooks)? How long would it take? **UPDATE:** So far, I have received a handful of helpful answers, but I realized that I need some specific pointers on the subject. So, here are my particular questions:   1. What are some good textbooks one can use to learn embedded development?   2. What specialized online communities can be helpful for an aspiring embedded developer (not counting general stuff like Stack Overflow, Reddit and so on)?   3. What are the most interesting blogs dedicated to embedded development?


Is it a bad practice having experience of anti-technologies?

I had this doubt since a long time , having enclosed in CV the experience or knowledge of technologies that are 'anti' to each other or rivals in real world. For e.g. - A guy having RHCE certification **and** MCSE certification will be preferred or rejected at sight ? In my view - he is having experience of both technologies so I'd prefer this guy `but I've heard that` people with this kind of CV are considered like- they didnt had it in their mind " What they want to do in future, What are their interests " etc etc ...


Relationship between user story, feature, and epic?

As someone whose still new to agile, I'm not sure I completely understand the relationship or difference between a user story, feature, and epic. According to this question, a feature is a collection of stories. One of the answers suggest that a feature is actually an epic. So are features and epics considered the same thing, which is basically a collection of related user stories? Our project manager insists that there's a hierarchical structure: Epic -> Features -> User stories ... basically all user stories must fall within this structure. Therefore all user stories must fall under an umbrella feature and all features must fall under an epic. To me, that sounds awkward. Can someone please clarify how user stories, features, and epics are related? Or is there an article that clearly outlines the differences?


Object oriented parser model review

First time I make use of Code Review. At the moment I'm creating an Android application and the company I'm developing it for, has a specific file format that can be used to give text based data specific formatting rules. See it as an rich text format especially build and designed for their use. # **The File format to work with** The file format was or at least is in my opinion designed to be used for pure formatting reasons and is actually not very well designed for data access. The Android application I'm writing depends very strongly on data access, that being said I had to design a smart parser which is capable of transforming the formatted text to some kind of data model which could still have the formatting included. A typical file could exist out of 600 lines of text having a total of 60000 characters. And could look like this:               \id sit amet     \ide UTF-8     \rem File version: 2013-06-18     \rem Copyright 1995-2012     \t Lorem ipsum     \h 1     \st Nunc at urna     \p     \v 1 Lorem ipsum dolor sit amet, consectetur adipiscing elit.     \v 2 Suspendisse ac turpis quis diam elementum cursus sit amet non urna.     \pq Vestibulum vulputate \nd dui\nd* eget pharetra adipiscing.     \pq Suspendisse viverra metus quis feugiat rutrum.     \v 3 Nunc at urna vehicula, luctus quam convallis, adipiscing metus.     \v 4 Integer sit amet neque condimentum, laoreet neque ut, feugiat tellus.     \h 2     \v 1 Nam commodo orci et magna eleifend imperdiet.     \v 2 Cras a lorem ac nunc interdum lacinia.     \v 3 Integer vestibulum mauris id scelerisque lacinia.     \st Ut molestie nibh     \p     \v 4 Duis aliquam \nd diam\nd* nec nisl hendrerit posuere.     \v 5 Donec eget sapien id purus sollicitudin elementum non eget arcu.     \b     \v 6 Fusce auctor justo vitae aliquam luctus.     \v 7 Phasellus eget nisl at dui dignissim pharetra.     \v 8 Mauris iaculis mi at augue mattis, eu bibendum nunc placerat.      The `\h` marker and the `\v` marker are the most important markers they are used to identify the data using the integer behind it. The other makers are mostly irrelevant (like the `\id, \ide, \rem` markers), and some like `\pq` are used to append their data to the line above it but with some formatting applied to it. And some markers are "in-text" like the `\nd` marker. Of course there are a lot of rules how the tags can be used in a valid file, but it's totally irrelevant for the review I think. (Or is there someone willing to read 90 pages?) # **The structure of the parser** So I came up with the following (Object oriented) parsing model: The parser has to be:   * **Able to separate DATA from FORMATTING**   * Fast    * separate the data and the formatting so both can be easily accessed   * Able to parse a subset of data or a specific range of data from a file A selection of data is often referred as: File - Level - Sub-level(actual data) Where the `file` is just a file to parse, the `level` an integer which can be found in the file by the `\h` marker and the `Sub-level` just like Level with the `\v` maker. The parser I wrote returns an object which holds two lists - one with all the formatting and one with all the data.               public class ParseResult {         protected ArrayList<FileData> data = new ArrayList<FileData>();         protected ArrayList<FileFormat> format = new ArrayList<FileFormat>();     }      The `FileData` object and the `FileFormat` object can be extended to create numerous different formats and data objects. This is the structure I use in the parser I wrote: For data:               FileData           -FileDataLocation extends FileData               -FileDataText extends FileDataLocation               -FileDataThing extends FileDataLocation           -FileDataAnotherThing extends FileData        For formatting:               FileFormat           -FileFormatLevel extends FileFormat           -FileFormatTitle extends FileFormat           -FileFormatSubLevel extends FileFormat           -FileFormatSpecialTokens extends FileFormat       To use data from the parsed file I use the data `ArrayList`. To print the data formatted I loop trough the format `ArrayList` which is sorted so that the beginning of the file would be at the 0 index of the list and the end of the parsed file the last index of the list. **Each formatting object has a reference to a data object in the data list. So that when using the formatting objects the data is always accessible. The formatting objects only hold information what peace of data the format should be applied to and what kind of formatting.** # **Parsing method** When parsing a file the parser reads the file line by line and constantly keeps track of the `\h` and `\v` markers, and starts capturing data in the `ParseResult` object when a specific combination of the markers is found (Lets call that a location). To check what type of marker the parser is dealing with I scan the line until I find the first whitespace. When a whitespace has been found a substring can be made from the start of the line to the location of the whitespace. Comparing the substring with a list of known makers tells the parser what to do with the line. After the marker is found the line is processed using regex. This is an example regex for a line with the `\v` marker:               \v\s(([0-9]{1,3})(?:-([0-9]{1,3}))?)\s{1}(.+)[\n\r$]*      # **Review?** The performance of the parser is not bad at all, the largest files take about 600ms to process completely (9000 lines, 280000 characters). Things I would like to know   * Data is now (after parsing) stored in just a list, searching for a specific peace of data is not very well optimized. Are there other structures I could use, which I can search using `file(string) - level(integer) - sub-level(integer)` so I can quickly get a specific data object.   * When looping trough the formatting list I must check what instance an object belongs to, and then cast the object so I can use the specific methods and functions. Is there a better, other, alternative method?   * The file format is pretty basic, should I consider removing all regex functions and parse it whole by just regular code?


Can someone help me in creating a dynamic programming solution to this problem?

I have some function names which are assigned to some nodes. I have to decide which functions to move to other nodes to increase speed. Why do I have to move the functions to other nodes? If communicating functions are on same nodes they take less time as compared to if communicating functions are on different nodes. A function might be communicating with several functions (all could be on different nodes). The question is which node do I move it to, to maximize the global performance. I need to find a globally optimal solution using dynamic programming. I have the following information   1. The integer value of the amount of data transferred between functions    2. The amount of time it takes to transfer data between nodes. Initially all functions have been assigned to some nodes. Can somebody help me in mapping this problem to the assembly line scheduling algorithm (Dynamic programming) or creating some other dynamic programming solution to this problem? The hard metric is the execution time of the entire program.The independent running time of a function is calculated by any timer API (We already have it). Its (function's) actual running time would be equal to its independent running time + the running time of all the functions which are producing data consumed by this function + the communication time between this function and other functions on same node + the communication time between this function and functions on other nodes. The program's running time would then be the sum of the running time of all the functions in the program. I have to minimize the execution time of the program which is the sum of the execution time of all the functions.Each functions execution time is the sum of its own time(precalculated) and the sum of all functions which will will execute before it and its sum with its time spent communicating with other functions(same or different nodes).


Opposite term of indent

We say that we indent code. I'm writing a string builder which can add/remove tabs to indent code. Sample:               builder.Add("
");     builder.Indent();     builder.Add("

");     builder.Dedent(); // <-- what should this be named.     builder.Add("
");         What should I name the method?


AJAX Requests & Client-Side JavaScript

I am new to AJAX and trying to understand a question I've been given: A HTTP request is generated by a form which contains some drop-down list. When the form is submitted, a new web page is displayed with some relevant text information (which is dependent on the list item selected). Now, the same parameters are sent to the server via an AJAX request, and the same text information is returned. Q. What tasks would the client-side JavaScript have to do to ensure a valid request was constructed and sent? Any useful links or quick explanations greatly appreciated.


What amount of time should be spent on bugs vs original development?

This question is a little abstract but I'm hoping someone can point me in the right direction. My question is what amount of time can one expect to devote to a software project's bugs in relation to the original development time. I realize there are a huge number of determining factors that go into but I was hoping for a typical or average breakdown. For example, if Project A takes 40 hours to complete and an additional 10 fixing bugs then this project would have a 4:1 ratio. If another Project (B) takes 10 hours to complete but another 8 on bugs then it would have a 5:4 ratio. Is this a documented/researched concept? ### UPDATE Thanks for all the informative answers. I understand that it's impossible to put a standard to this kind of metric due to all the variables and environmental factors involved. Before I assign an answer I'd like to know if this metric has an agreed-upon name so I can do further research. I would like to get to a point where I can understand the measurements necessary to generate the metrics myself and eventually come up with a baseline standard for my project.


programming contract work and copyrights

Quick question guys. It may be country dependent so this question is more directed towards EU citizens. If I did a programming job, raised an invoice but never got paid, am I still holding the copyrights and can disallow use of the software? No specific contract regarding copyrights was signed upfront. I don't know if you can help, but though asking you guys may be worth a shot


Reuse Other Company's Content For Same Client

Here's the scenario: a client of mine (lets call them Company A) had a website built by someone else (let's call them Company B). They then asked me (Company C) to configure a third party framework to look and feel exactly the same as what Company B built for them. Would it be legitimate for me to use content (including images, CSS, and even HTML) from the site Company B built for Company A? It's worth mentioning Company A's name is in the copyright notice in the footer of the site Company B made for Company A.


Understanding "programming to an interface"

I have come across the term "programming to an interface instead of an implementation" a lot, and I think I kind of understand what it means. But I want to make sure I understand it's benefits and it's possible implementations. "Programming to an interface" means, that when possible, one should refer to a more abstract level of a class (an interface, abstract class, or sometimes a superclass of some sort), instead of refering to a concrete implementation. A common example in Java, is to use: `List myList = new ArrayList();` instead of `ArrayList myList = new ArrayList();` . I have two questions regarding this:   1. I want to make sure I understand the main benefits of this approach. I think the benefits are mostly flexibility. Declaring an object as a more high-level reference, rather than a concrete implementation, allows for more flexibility and maintainablity throughout the development cycle and throughout the code. **Is this correct? Is flexibility the main benefit?**   2. Are there more ways of 'programming to an interface'? Or is "declaring a variable as an interface rather than a concrete implementation" the the only implementation of this concept? **EDIT: Clarification** \- I'm **not talking about the Java construct Interface**. I'm talking about the OO principle "programming to an interface, not an implementation". In this principle, **the world "interface" refers to any "supertype" of a class** \- an interface, an abstract class, or a simple superclass which is more abstract and less concrete than it's more concrete subclasses.


Should I take a C# certification course to learn C#?

I'm looking to learn C# mainly so i can get into XNA. I know the basics of programming and I've tooled around with GameMaker, which has it's own scripting language. I'm not really looking to jump into the industry and honestly I'm not sure I would ever want to program for a living. However, I'm having a hard time teaching myself with tutorials and I thought taking a class might be worthwhile. The school I'm looking to attend is a community college and they offer a certification course in C# and I might take it if I find it worth the price. My question is, **will it be worthwhile**? I know it depends largely on the school and the instructors but by taking a certification course will I learn any more than I would by just shelling out the same amount of money into some decent books?


Asked to put in extra hours

I'm working through exactly what the best approach is to being asked by an employer as a team to put in extra hours both during weekdays but also an additional day on weekends (6-8 hours). No additional compensation (overtime, additional time off, etc...) is a part of the arrangement; I think from their perspective it's about being able to keep the job. We work in 6 week cycles, so the duration of this "crunch time" is the length of the cycle. The entire project team are salaried (exempt), not hourly. After the cycle is complete if it is judged that the project is in "better shape" then we will go back to our normal expected hours of the typical 40-hour work week. Any thoughts, advice, or previous circumstances like this from which you might have emerged the better?


Should I start developing in Python 3?

> **Possible Duplicate:**   >  Should we use python 2.6 or 2.7 or 3.x? Now that Django runs on Python 3, I think it's time to ask that all-important question: Should I start using Python 3 instead of Python 2? It really seems that though 3 has a lot of awesome new helpful features, everyone's sticking to 2. Are Python 2 libraries forward-compatible with Python 3? For example, will I lose all of my Django apps which have been developed for Python 2?