答:
At many companies, there is a technical ceiling, in terms of compensation.

So if you want more money, it's management or consulting.


问:
How should I create lo-fi (non-interactive) UI prototypes?
I'm currently working on throwing together some basic prototypes, partly to gather requirements and partly to design the final UI.

At the moment I'm trying building up the screen using Post-it notes, with yellow notes for information and pink for actions (buttons or menus). The idea being that you can easily move, remove and add information. But I'm sure there are more efficient methods out there.

What is the recommended way for developers to efficiently create non-interactive UI prototypes?

And why?

I tried some pen, paper and Post-it note versions and they went down like a lead balloon (likely my drawing skills). In the end I used Balsamiq, which thus far is liked by most users and they get it is prototype. Alas, some people are still having problems with the idea that first one should get an idea of what the application should do via some lo-fi prototypes and really want to "see something on the screen" before committing to anything.

答:
Balsamiq mockups are usually the first port of call, almost as quick as using a pen and paper and reusable.

Plus you can add some degree of interactivity if you wish, linking pages together for example.

http://balsamiq.com/

ContentLicense: CC BY-SA 3.0

ContentLicense: CC BY-SA 2.5


问:
Do non-manager coders in their forties or older out there sometimes regret about not being managers?
And why do most programmers quit coding and become managers so early compared to other areas? You can work as a construction worker, a lawyer, researcher, writer, architect, movie director for decades if not your whole life, without quitting the favorite thing you are doing. And yet most programmers think being a manager, or better, a non-coding manager is a cool thing and the ultimate goal of the software career. It's so rare to see an ordinary coder in his 40s or 50s (or 60s!) in a typical software company. Why?

(And I am for being a coder for as long as you love doing it.)

答:
Some obvious reasons:

Money (managers are paid better)

Laziness (as a developer you have to learn all the time to keep your knowledge up-to-date)

Desire for change (the most of the people after 40 are just tired of coding)


答: I can give a short answer to that: I've gotten promoted to "management" positions twice. Each promotion was followed fairly quickly by a resignation (admittedly, in one case I was getting pretty burnt out there anyway, but being made a manager was one of the last straws).</p>

Title: Do non-manager coders in their forties or older out there sometimes regret about not being managers?

Body:
And why do most programmers quit coding and become managers so early compared to other areas? You can work as a construction worker, a lawyer, researcher, writer, architect, movie director for decades if not your whole life, without quitting the favorite thing you are doing. And yet most programmers think being a manager, or better, a non-coding manager is a cool thing and the ultimate goal of the software career. It's so rare to see an ordinary coder in his 40s or 50s (or 60s!) in a typical software company. Why?

(And I am for being a coder for as long as you love doing it.)


问:
Do you ever read language specs?
While trying to answer questions on SO site (particularly C++ questions) I find that most of the times one person or the other includes a quote from the standard. I myself have hardly read the language spec. Even when I try to read it, I can't get my head around the language used in the specs. So, my question to become a good developer in a particular language is it essential to read its spec and know all its dusty corners which invoke undefined/implementation defined behavior? </p>

答: I've read an annotated version of the C# Spec (for version 3 I think). I can't say that I learnt anything mindblowingly new (I'm sure I learnt a bit but nothing stands out in my mind) but I did get a a deeper understanding of why things are the way they are. I found the annotations really valuable where they explored compromises that had been made in one or another. For me at least, this background knowledge makes things stick in my mind much better and I think I'm a much better developer as a result.</p>

Title: Do you ever read language specs?


答:
Knowing the C++ spec (being able to look things up, or quote it on StackOverflow) is relatively important for C++ because the language has lots of undefined behavior that compiler implementers can do whatever is convenient with those undefined areas. Just because your compiler accepts the code and just because it runs correctly doesn't mean it's portable. You may be relying on features of your architecture, features of your operating system's ABI/API, or features of your compiler (or of a particular version of your compiler). So to know what's portable C++, and what guarantees you can rely on, you need to refer to the spec. Your compiler won't know.

Most other languages leave a lot less program behavior explicitly undefined, so you refer to the spec to the extent that you find it useful as an API reference.

Title: Do you ever read language specs?

Body: While trying to answer questions on SO site (particularly C++ questions) I find that most of the times one person or the other includes a quote from the standard. I myself have hardly read the language spec. Even when I try to read it, I can't get my head around the language used in the specs. So, my question to become a good developer in a particular language is it essential to read its spec and know all its dusty corners which invoke undefined/implementation defined behavior? </p>


答:
Do non-manager coders in their forties or older out there sometimes regret about not being managers?

Not me.

Why do most programmers quit coding and become managers so early compared to other areas?

There are a couple of reasons. One has to do with age discrimination, it gets much much harder to land new programming positions after 40. Another was described to me by one programmer-turned-manager: "the problems I now like to solve are ones I can't solve by being a single programmer, they are too big and need more than 1 programmer to do them."

It's so rare to see an ordinary coder in his 40s or 50s (or 60s!) in a typical software company. Why?

Age discrimination along with "I'm tired of putting up with this stupid crap!" [1]

I'm 50. I know 2 other programmers who are 55. One had to move to be near Washington DC to get away from the age discrimination around here. The other is stuck in VB6-land (we do mostly .NET now, but one cash cow product is still in vb6), and he was a project manager at one previous job. The combination of ageism and offshoring [2] and the much harder difficulties of folks just a few years older than me is a strong message that I need to be considering some Plan B alternative career. My guess is that I have 15-20 years left in the workforce before I can afford to retire. I don't know what the future holds, but from my view, it doesn't look very appealing. Programming has been a great ride, I don't see it lasting forever.

Notes:

1 - A single, or at least childfree/childless developer can devote far more time to work than someone who says "I can't stay late tonight, I have to pick the kid up from daycare." Too much requesting/demanding of overtime leads developers to seek positions where they can spend time with family instead of with code.

2 - I don't see offshoring killing my job in particular, just strangling the flow of new, entry-level developers into the industry. Consequently, the mid and senior level programmers are fading away with few junior devs behind them. As the folks in other countries get the development skills, many of them will move up into mid and senior level dev positions further reducing an already hard (for me at my age) market.


问:
Making simple forms in web applications
How do you work with forms in your web applications?

I am not talking about RESTful applications, I don't want to build heavy front-end using frameworks like Backbone.

For example, I need to add "contact us" form. I need to check data which was filled by user and tell him that his data was sent.
Requirements:

I want to use AJAX.

I want to validate form on back-end side and don't want to duplicate the same code on front-end side.

I have my own solution, but it doesn't satisfy me. I make an AJAX request with serialized data on form submit and get response. The next is checking "Content-type" header.

html -> It means that errors with filling form are exists and response html is form with error labels. -> I will replace my form with response html.

json and response.error_code == 0 -> It means that form was successfully submited. -> I will show user notification about success.

json and response.error_code != 0 -> Something was broken on back-end (like connection with database).

other - I display the following message :

We have been notified and have started to work with that problem. Please, try it later.

The problem of that way is that I can't use it with forms that upload file.

What is your practise? What libraries and principles do you use?

答:
Your process does not look bad to me, and we have processed a lot of forms.

We use a custom Form library for our bespoke system which works very well for the simple applications of forms.  You have to be careful though as something like this can quickly become restrictive (and worked around) from a design perspective.

Our application works mostly like yours, in that we post back the form, and replace the form again in the UI, but we send back a standardised xml response, which a generic jQuery library processes, part of the response is the replacement HTML.

The backend is object based, so we add controls to a Form object, and validation rules to controls.  This gives us a very structured way of handling postbacks, and building forms with validation.  Our client validation is built by exactly the same rules we feed into our form controls.  On the server side all (most) form processing is handled in exactly the same solid standardised way.

check for postback -> get posted form -> check validates -> process

We don't have the library build the form as one block output (we have made this mistake before), it is far too restrictive from a design perspective, in basis this means don't have form->Render() output an entire form, rather have form->getControl('firstname')->Render() so that you can easily integrate with any required front end with custom interface between all form elements, we then further have macro’s that we can use in our template system to make prototyping faster: {frm1[firstname]}

We have standardised the response format, and the request mechanism, this means we have one javascript library for all of our purposes, we don’t have inline JavaScript for form processing everything is generic.

However, designers hate that they can’t see library generated forms in their HTML design tools. The macros help with this as they are at least visible as a place-holder.

We handle file upload fields in an iframe.  It gives the impression that an ajax file post is occurring, even  if it is not. Remember so long as you are not cross domain you can use JavaScript to communicate between parent and iframe.

EDIT  Worth mentioning that all forms are valid HTML forms, they are improved by Javascript when it is available, again the library is standardised.

Title: Making simple forms in web applications


问:
What are the advantages of using the Java debugger over println?
I always use System.out.println(...) to debug my code, and it works pretty well. In which cases do you use the eclipse java debugger? I never had to use it and the little bug symbol is still ab bit mysterious to me. Are there cases where the debugger helps me that I can´t solve with a println?

答:
I hardly ever find that I need the debugger - but when I need it, I really need it.

One nasty case is where you use println to print out an object, and it prints out "null". After staring at the code for ages, you are convinced that the object cannot be null at that point. And yet, that is what println says. This can waste hours.

In the debugger, you will find immediately that the object is not null. However, the toString() method has been over-ridden to print out the value of some field in that object. The value of this field is, of course, null.

The debugger lets you explore a wider range of questions, more quickly, than using println. But in many simple situations, println is good enough. Just don't waste too much time in those cases when it isn't good enough.


问:
Can WinRT really be used at just the boundaries?
Microsoft (chiefly, Herb Sutter) recommends when using WinRT with C++/CX to keep WinRT at the boundaries of the application and keep the core of the application written in standard ISO C++.

I've been writing an application which I would like to leave portable, so my core functionality was written in standard C++, and I am now attempting to write a Metro-style front end for it using C++/CX. I've had a bit of a problem with this approach, however. For example, if I want to push a vector of user-defined C++ types to a XAML ListView control, I have to wrap my user-defined type in a WinRT ref/value type for it to be stored in a Vector^. With this approach, I'm inevitably left with wrapping a large portion of my C++ classes with WinRT classes.

This is the first time I've tried to write a portable native application in C++. Is it really practical to keep WinRT along the boundaries like this? How else could this type of portable core with a platform-specific boundary be handled?

答:
IMHO (old programmer; work at Microsoft but this is a personal opinion): before I can answer this question, you have to anwser this other question:

Where is the code moving to?  If you're sticking with a single platform (in this case, WinRT), then be close to the platform -- and that means using the existing abstractions.  Per your example, your code would then use Vector^ in order to match the WinRT needs.

OTOH, if you're moving somewhere else (VMS rocks!), then standards based makes sense.

Given that the three biggest portable, tablet-like platforms in the marketplace all use different languages for common programming tasks, moving the code might not be a valuable option.


答:
in my experience, the eclipse debugger (or any step-by-step debugger, for that matter) helps a lot more than println statements, because:

they don't require several recompiles for what might be a small problem (this might seem like a small problem for small projects, but can quickly escalate for large to very large ones)

they often allow debugger-time altering of the variables, which might be handy as well.

(these are just the most basic advantages I found)

However, the debugger is not always that nice:

debugging multithreaded programs with a step-by-step debugger is pure hell. In the first writing step, I usually use a logging system with a byte-by-byte debug flag (think global debug, module 1 heavy debug, module 2 heavy debug, ...). It's saved me a lot so far

debugging real-time programs where the real-time character is vital to the algorithm (the thing I have in mind was my personal version of face detection, which required the face to move smoothly. It didn't when only getting a frame every couple of seconds because of debugging - granted that this could be solved by taking a video input, just giving an example)

in short: for small, handable projects a debugger is your largest friend. For large projects (which you often work on with a lot of people), an extensive write-time logging is your even larger friend. Or at least mine.

Title: What are the advantages of using the Java debugger over println?

Body: I always use System.out.println(...) to debug my code, and it works pretty well. In which cases do you use the eclipse java debugger? I never had to use it and the little bug symbol is still ab bit mysterious to me. Are there cases where the debugger helps me that I can´t solve with a println?


问:
Guidelines for creating referentially transparent callables
In some cases, I want to use referentially transparent callables while coding in Python. My goals are to help with handling concurrency, memoization, unit testing, and verification of code correctness.

I want to write down clear rules for myself and other developers to follow that would ensure referential transparency. I don't mind that Python won't enforce any rules - we trust ourselves to follow them. Note that we never modify functions or methods in place (i.e., by hacking into the bytecode).

Would the following make sense?

A callable object c of class C will be referentially transparent
  if:

Whenever the returned value of c(...) depends on any instance attributes, global
  variables, or disk files, such attributes,
  variables, and files must not change for the duration of the program
  execution; the only exception is that instance attributes may be
  changed during instance initialization.

When c(...) is executed, no modifications to the program state occur that
  may affect the behavior of any object accessed through its "public interface"
  (as defined by us).

If we don't put any restrictions on what "public interface" includes, then rule #2 becomes:

When c(...) is executed, no objects are modified that are visible outside
  the scope of c.__call__.

Note: I unsuccessfully tried to ask this question on SO, but I'm hoping it's more appropriate to this site.

答:
The goal of enforcing referential transparency (RP) may be a bit ambitious given the presence of file IO and global variables. Instead, you can make it a best practice, which basically seems like that you wish to do.

Rules 1 and 2 will certainly push you into the direction of RP, but they are somewhat problematic. First of all, relying on the fact that a disk file doesn't change is risky. It is best to isolate IO to well defined parts of application code. The same holds for global variables. While it is true, that if global variables used by a function don't change, it would allow for RP, it may be too difficult to enforce. Instead, try to avoid global variables. Also, ensure that instance attributes are read-only.

Given that Python is a multi-paradigm language, you can reap the benefits of functional programming as well as OOP. You can structure code such that there are purely functional parts which adhere to RP and there are imperative parts which glue everything together. OOP can be said to structure programs by encapsulating moving parts while FP can be said to reduce moving parts - use both paradigms.


问:
Rapid prototyping and refactoring
Sometimes when I start a small project (like an android app), I don´t know which approach will work out at the end, and I just go for one approach and give it a try. But if I never used this approach before (for a sort of application I´ve never programmed before) it is like stepping into unknown terrain. I don´t know which libraries to use (maybe I have to try out several libraries) and there are so many unkonwns (like: how to get raw audio data in android)

So then my development process goes like this:

Write a piece of code to see if the approach has a chance. (The more uncertain the approach is, the uglier the code gets)

If it works, refactor a lot until it is beautiful

I think it could be a waste of time if I planned my software design in detail at this point, it would be like planning a trip without a map.

Is this part of aglie development?
How do you deal with unknown terrain in software development?

答:
That has nothing to do with agile, but people sort of assume it does because that's what they think Agile is; headless chicken development in a hippy commune.

What you are doing is assessing technologies because you don't currently have enough experience of them to make a judgement call. This is good and never ends because new libraries, frameworks, languages and platforms appear almost daily.

How you deal with the unknown is a really good question actually and it comes down to researching the alternatives, assessing them and then selecting one.

The skills which tend to become associated with Agile that help here involve making code that is as easy and safe to refactor. TDD is good example. It encourages you to consider your development in terms of outcomes. "This code should produce this result" which focuses the mind and reduces the amount of code which doesn't contribute towards solving the goal.

If you write code following SOLID (Acronym) principles, you will be in a good position later to replace a library if you made the wrong choice, or, as so often happens, you outgrow your choice.

It's good that you ask this sort of question. There are too many developers who for various reasons will not risk appearing "ignorant" by taking time to select the correct technology. Make mistakes early in the project not late. Experimentation is key not a waste, so I think you're going about it the right way.

Title: Rapid prototyping and refactoring


问:
Predicting advantages of database denormalization
I was always taught to strive for the highest Normal Form of database normalization, and we were taught Bernstein's Synthesis algorithm to achieve 3NF. This is all very well and it feels nice to normalize your database, knowing that fields can be modified while retaining consistency.

However, performance may suffer. That's why I am wondering whether there is any way to predict the speedup/slowdown when denormalizing. That way, you can build your list of FD's featuring 3NF and then denormalize as little as possible. I imagine that denormalizing too much would waste space and time, because e.g. giant blobs are duplicated or it because harder to maintain consistency because you have to update multiple fields using a transaction.

Summary: Given a 3NF FD set, and a set of queries, how do I predict the speedup/slowdown of denormalization? Link to papers appreciated too.

答:
I imagine that de-normalizing too much would waste space and time

Space is not to worry about in most medium size Line of Business OLTP applications. So leave space aside. Time, and by time I assume you mean performance of query, that is something that can usually be enhanced and does not cause a real issue unless you have a bad design, insufficient resources, extremely large database, very large number of transactions or all of the above. Most applications using today's databases would rarely have a performance problem only because the database is Normalized.

giant blobs are duplicated or it because harder to maintain consistency because you have to update multiple fields using a transaction.

Normalizing your database assures you that you design will:

Not have redundant data.

Not cause huge number of log enteritis to be created (ex with a table of 2 Million customers: UPDATE Customer Set Country="USA" WHERE Country="US")

Be supported fully be SQL Queries. This point is very important.

Will drive clean application code.

Force a high degree of data consistency via the database without burdening the application.

Share business rules defined in the database by different applications without coding the same code in different applications.

Having said that, Normalization produces optimal structure for all columns and tables. This you may not always need in your particular application, you then could determine, given your understanding of your domain and your application, to de-normalize some of the tables/columns as a trade-off for speed. However, that would be a conscious decision rather than an oversight.

Given a 3NF FD set, and a set of queries, how do I predict the speedup/slowdown of de-normalization?

You can't predict performance accurately without testing (which you can do before you write the application code). However, you can eliminate and detect factors that would lead to bad performance by design. For example, you can identify what index strategy to use as follows (other techniques may exist):

Build a matrix of queries and columns affected by those queries.

Find columns that are used the most.

Consider building indexes on those columns.

This is mainly a job where your DBA could assist you with. There is more to performance than Normalization. There are aspects of data distribution over disk volumes, vertical table splitting, partitioning,  index types and index buffering to name a few. All of such techniques should be addressed in books and vendor documentation under "Database Design" and "Database Performance Tuning" subjects. All of the above discussion assumes your application is an OLTP applications.


答:
Is this part of aglie development? How do you deal with unknown terrain in software development?

What you have described is not Agile. The Agile development is more about  promoting adaptive planning, evolutionary development and delivery with a time-boxed iterative approach. Agile does encourages rapid and flexible response to change. Thus, re-factoring your code as development progresses have pieces of Agile methodology in it.

Dealing with un-known piece of the project starts with gathering the known requirements, with high-level design. Once you get most components on hand, you may search for the right solution. That said, building small proof-of-concept before full-blown development is the approach that our team follows.

There is a software development principles called SOLID. In my experience, applying them on issues/problems is always a step forward in improving your project's code base.

Title: Rapid prototyping and refactoring

Body:
Sometimes when I start a small project (like an android app), I don´t know which approach will work out at the end, and I just go for one approach and give it a try. But if I never used this approach before (for a sort of application I´ve never programmed before) it is like stepping into unknown terrain. I don´t know which libraries to use (maybe I have to try out several libraries) and there are so many unkonwns (like: how to get raw audio data in android)

So then my development process goes like this:

Write a piece of code to see if the approach has a chance. (The more uncertain the approach is, the uglier the code gets)

If it works, refactor a lot until it is beautiful

I think it could be a waste of time if I planned my software design in detail at this point, it would be like planning a trip without a map.

Is this part of aglie development?
How do you deal with unknown terrain in software development?


问:
How to select an appropriate Nvidia GPU for learning CUDA
What would be a good GPU to start learning CUDA on?

Are any GPUs unsuitable?

答:
Virtually any card made by nVidia in the last 5 years can be used to run CUDA programs. In terms of "Best", you'd probably want a Tesla but they are hideously expensive. By hideously expensive, I mean that they are designed to operate only as computing on GPU hardware and not as regular graphics cards. You mount them in servers and "Do Science" to things with them. You can technically mount one in a workstation but it's still expensive. A bare minimum machine from Dell, for example, is just under $5000.

As far as home applications, whatever card you've got would probably work fine provided that it's on this list. Pick something you can afford. Find some problems that are of interest and amenable to the SIMD(SPMD) architecture and have at it. Finding a reference for C is recommended as well as a CUDA guide. If you don't yet know any C, Zed Shaw will cure you of that.


答:
Depends on the project, if you are working alone on a small project, it might make perfect sense to perform your tech research and investigation as part of the development.  And although not a part of Agile, of course an Agile methodology could be used to add some control to this. However this makes the process very hard to predict /or time box.  Might be fine, even faster, if working alone on a small project that is wholly yours,  let your requirements unfold as you learn them.  Use good principles along the way, and be consistent and you shouldn't need to re-factor so much.

At work we use Kanban, Scrum, and more traditional waterfall approaches. Depends on the project,  I find that complex developments with well defined up front requirements are not best suited to agile, many will disagree though.

Before we start work even on an agile project (all but the most simple that is), we create some documentation.  We have a mock up (if ui focused), a set of requirements, and a functional spec.

Development will be asked to create the technical spec from the functional spec, and during this process we will specify technology and perform any up-front research that we need to.  This process seems so important to me, as it gives the opportunity to see gaps in the requirements / functional specs - and gives the big technology decisions up front to the people with the experience and system knowledge to make such decisions.

The significant thing though, is that the functional spec could be a list of bullet points, and the tech spec will usually be a model, with some bullet points and technology steers, maybe just 3 or 4 pages in some cases.

Even when running an agile project we create documentation:

All documentation has a cost.

Developing against moving and ill-define high level requirements has a cost.

The correct balance to the above depends on your project, the culture, and the people.

We document Just in time, documents come out of date.

We document barely enough / just enough.

We do not maintain or update these documents, we don't put much effort into them. They are small.  We expect to throw them away.

We iron out the big unknowns such as technology decisions, hazy requirements, and architecture up front.

We know what we are developing before we start.

We trust the developers to make informed decisions around the documentation and discuss any issues.

We value communication over documentation, as such we expect all involved to communicate often.

We document systems (overview) after development, not during, not before.

You see there is a small waterfall in our agile process.

If you work alone,  create an upfront model (diagram!)  and play with and choose the tech, and then when you have this concept of the high-level requirements, run ahead and develop in an agile iterative way, but consider good principles and consistency as you go and you will need to re-factor less,  more re-factor as you go.

But in general,  if there is a real cost involved (not a hobby) know what your are developing before you write code, but don't waste too much time writing documentation that will become redundant fast as you will change your mind, and should change your mind during development as you become better informed.  And your project could change course hugely, but start from a good, well defined foundation.

Title: Rapid prototyping and refactoring


问:
What am I allowed to do programmatically with pictures that have a Creative Commons "don't modify" license
I'm working on a project that uses some icons that are under a Creative Commons license (ND) that forbids modification of the picture.

What can I do with this icons as a programmer?

Can I modify the looks of the image in the program as long as I don't change anything in the file that contains the icon?

Have I modified the image if I put a colored transparent layer over it so the color of the icon changes?

答:
As a simple wikipedia search would have told you, this changes based on the kind of Creative Commons imposed by the original artist

http://en.wikipedia.org/wiki/Creative_Commons#Types_of_Creative_Commons_licenses

In my experience, finished graphics tend to come under the "Attribution Non-Commercial No Derivatives". In the end, contacting the artist is the best way (which you should do anyway if you use his work somewhere publicly)


问:
How to avoid javascript becoming spaghetti code?
I've done quite a lot of javascript over the years and I'm using a more object-oriented approach, specifically with the module pattern. Which kind of approach do you do use to avoid a bigger code-base to becoming spaghetti. Are there any "best approach"? </p>

答:
Code standards in general are useful.

That means:

Modules are definitely necessary. You also need consistency in the way "classes" are implemented, i.e. "methods on the prototype" vs "methods on the instance". You should also decide which version of ECMAScript to target, and if you are targeting i.e. ECMAScript 5 use the provided language features, (e.g. getters and setters).

See also: TypeScript, which could help you standardize e.g. classes. A bit new at the moment, but I don't see any disadvantages in using it since there is hardly any lock-in (because it compiles to JavaScript).


问:
Why are UUID / GUID's in the format they are?
Globally Unique Identifiers (GUID) are a grouped string with a specific format which I assume has a security reason.

A GUID is most commonly written in text as a sequence of hexadecimal
  digits separated into five groups, such as:

3F2504E0-4F89-11D3-9A0C-0305E82C3301

Why aren't GUID/UUID strings just random bytes encoded using hexadecimal of X length?

This text notation contains the following fields, separated by
  hyphens:

```<code>| Hex digits | Description
|-------------------------
| 8            | Data1
| 4            | Data2
| 4            | Data3
| 4            | Initial two bytes from Data4
| 12           | Remaining six bytes from Data4
</code>```

There are also several versions of the UUID standards.

Version 4 UUIDs are generally internally stored as a raw array of 128
  bits, and typically displayed in a format something like:

uuid:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx

答:
From RfC4122 – A Universally Unique IDentifier (UUID) URN Namespace

The formal definition of the UUID string representation is provided by the following ABNF:

```<code>UUID                   = time-low "-" time-mid "-"
                         time-high-and-version "-"
                         clock-seq-and-reserved
                         clock-seq-low "-" node
</code>```

So, those are just the different fields from the original time and MAC-based UUID. The RFC says it originates from the Apollo Network Computing System.

OwnerDisplayName: Xeoncross

Body:
From RfC4122 – A Universally Unique IDentifier (UUID) URN Namespace

The formal definition of the UUID string representation is provided by the following ABNF:

UUID                   = time-low "-" time-mid "-"
                         time-high-and-version "-"
                         clock-seq-and-reserved
                         clock-seq-low "-" node

So, those are just the different fields from the original time and MAC-based UUID. The RFC says it originates from the Apollo Network Computing System.


问:
Is it unusual for a small company (15 developers) not to use managed source/version control?
It's not really a technical question, but there are several other questions here about source control and best practice.

The company I work for (which will remain anonymous) uses a network share to host its source code and released code.  It's the responsibility of the developer or manager to manually move source code to the correct folder depending on whether it's been released and what version it is and stuff.  We have various spreadsheets dotted around where we record file names and versions and what's changed, and some teams also put details of different versions at the top of each file.  Each team (2-3 teams) seems to do this differently within the company.  As you can imagine, it's an organised mess - organised, because the "right people" know where their stuff is, but a mess because it's all different and it relies on people remembering what to do at any one time.  One good thing is that everything is backed up on a nightly basis and kept indefinitely, so if mistakes are made, snapshots can be recovered.

I've been trying to push for some kind of managed source control for a while, but I can't seem to get enough support for it within the company.  My main arguments are:

We're currently vulnerable; at any point someone could forget to do
one of the many release actions we have to do, which could mean whole
versions are not stored correctly.  It could take hours or even days
to piece a version back together if necessary

We're developing new features along with bug fixes, and often have to delay the release
of one or the other because some work has not been completed yet.  We also have to force
customers to take versions that include new features even if they just want a bug fix,
because there's only really one version we're all working on

We're experiencing problems with Visual Studio because multiple
developers are using the same projects at the same time (not the same
files, but it's still causing problems)

There are only 15 developers, but we all do stuff differently; wouldn't
it be better to have a standard company-wide approach we all have to
follow?

My questions are:

Is it normal for a group of this size not to have source control?

I have so far been given only vague reasons for not having source control - what
reasons would you suggest could be valid for not
implementing source control, given the information above?

Are there any more reasons for source control that I could add to my
arsenal?

I'm asking mainly to get a feel for why I have had so much resistance, so please answer honestly.

I'll give the answer to the person I believe has taken the most balanced approach and has answered all three questions.

Thanks in advance

答: LordScree, I am in an almost identical predicament as you, my immediate team is about 15 developers.  I am in disbelief (almost horror) that source control is not used.  My initial response to "we should be using source control" was "we don't have time to implement". To me, like wearing underwear, source control is not optional.  After a few months, I too have approval to implement TFS, chosen by the org because it is MS and comes with a 90 day trial.  Bottom line, it is very difficult to convince an organization of the need for source control when they've been chuggling along without it.  I tell developers that anytime you find yourself backing up files, especially with a date in the backed up filename or directory, is an example of when you'd put something in source control.  I don't have any brilliant answers for you, but I do believe this is uncommon.   I'm fighting the same battle and will keep you posted on progress.  And, hopefully there will be progress else I may looking elsewhere cause I can't work in chaos!</p>

OwnerDisplayName: LordScree


答:
Dan Wahlin gives specific guidance about avoiding function spaghetti code in JavaScript.

Most people (including myself) start out writing JavaScript code by adding function after function into a .js or HTML file. While there’s certainly nothing wrong with that approach since it gets the job done, it can quickly get out of control when working with a lot of code. When lumping functions into a file, finding code can be difficult, refactoring code is a huge chore (unless you have a nice tool like Resharper 6.0), variable scope can become an issue, and performing maintenance on the code can be a nightmare especially if you didn’t originally write it.

He describes a few JavaScript design patterns that give structure to the code.

I prefer the revealing prototype pattern. My second favorite is the revealing module pattern, which differs slightly from the standard module pattern in that you can declare public/private scope.

Title: How to avoid javascript becoming spaghetti code?

Body: I've done quite a lot of javascript over the years and I'm using a more object-oriented approach, specifically with the module pattern. Which kind of approach do you do use to avoid a bigger code-base to becoming spaghetti. Are there any "best approach"? </p>


问:
Does your team function well without following a work methodology (such as scrum)?
I've worked in a number of small teams over the last 9 years. Each had the obvious good practices, such as short meetings, revision control, continuous integration software, issue tracking and so on.

In these 9 years, I've never heard much about development methodologies; for example, there's never been a "we're doing scrum", or "lets do agile", or anything more than a passing reference. All of the teams seemed to function fine, without following much process, we were just freeflowing and just naturally worked well.

Has anyone else progressed for long periods of time without encountering scrum/agile/etc?

The only exposure I've had to these is through sites like this one. I read questions like Sprint Meetings - What to talk about ... and all the talk seems to describe almost robotic like people who follow a methodology finite state machine. Is it really (though exaggerated) like that? I wonder if the  people posting on the internet just loud supporters of "best practice", with similar textbook views, not really reflecting how people work... Or that I've encountered some teams making their processes up naturally.

Furthermore (I am in the UK, which may be relevant)... I think if a methodology were introduced to any of the teams I'd work on, they'd just reject it as being silly and unnecessary... then carry on. I'd tend to agree, following processes seems a bit unnatural. Is this typical or common?

答:
If you have no problem to solve, lucky you.

I've seen many teams (especially in very small companies) working well without any defined methodology.

Implementing a methodology (or technique) because it's fun or because you read that blog post on the internet is very dangerous.

If you are fine, don't change anything. Just try some optimizations when you can.

OwnerDisplayName: Sam


答:
Technically, if your application displays the image changed, it could be considered a derivated work, hence the author would be within his right to sue you. Creative Commons licenses are not software licenses, with differences between static or dynamic linking and such. The same way displaying a copyrighted image might be illegal even if it is not available as a separated file in your application, displaying the ND image changed — other than resizing, I guess — could be considered illegal even if the actual installed file is not changed.

Your best shot, as suggested by Doness, would be to ask the author to allow you explicity to include the icon changed in your application, or even better, publicly relicense it under a different, more permisive license (e.g. BY-SA).

Title: What am I allowed to do programmatically with pictures that have a Creative Commons "don't modify" license

Body:
I'm working on a project that uses some icons that are under a Creative Commons license (ND) that forbids modification of the picture.

What can I do with this icons as a programmer?

Can I modify the looks of the image in the program as long as I don't change anything in the file that contains the icon?

Have I modified the image if I put a colored transparent layer over it so the color of the icon changes?


问:
What are the differences between Special Edition and the Third Edition of Stroustrup's The C++ Programming Language?
I'm buying a few C++ books after moving from Java. I obviously want to read the reference manual from the man himself, though I cannot tell the difference between these two editions. The special edition is ten pages shorter than the third edition. However, the special edition is recommended over the third edition and it seems this version covers the ISO standard when the other edition does not.

Can anyone shed a bit of light on this?

答:
From Stroustrup's own homepage (right at the top):

The "special edition" is the hardcover version of the 3rd edition. It
  differs from the early printings of the 3rd edition by about 1,000
  corrections and clarifications, by two new appendices (just over 100
  pages; also available online, see below), and by an improved index.
  The only difference between the current printings of the special
  edition and the 3rd edition is the cover (and the price difference
  implied by that stronger cover).

(The bold emphasis is mine.)

A little more from his FAQ section:

Should I buy the "Special Edition" of "The C++ Programming Language"?

Sure! Buy it early and often :-)

Seriously, the difference between the current printings of the special
  edition and the 3rd edition is just the hard cover (and the price
  difference implied by that stronger cover).

If I were a C++ programmer who hadn't read The C++ Programming
  Language (3rd Edition), I'd buy and read either the 3rd edition or the
  special edition. If I used my textbooks and references heavily, I'd
  choose the hard cover. The cover on the 3rd is the best soft cover
  available, but it doesn't equal the special edition's hard cover.

If I already had the 3rd edition, I'd buy the SE if my current copy
  were fraying or if my copy were an early printing (the 3rd now has
  about 30 printings and SE about 20).

Compared to the first printing, the special edition and the most
  recent printings of the 3rd edition have 1,000+ corrections and
  clarifications. As a heavy C++ user, I find that significant. There
  are also the two new appendices (just over 100 pages; available for
  download: Locales and Standard-Library Exception Safety).

Existing material has not moved around so page numbers can be used to
  refer to material in old printings, new printings of the 3rd edition,
  and in the SE.

The SE also has an improved index.


问:
Detect duplicate in a subset from a set of elements
I have a set of numbers say :  1 1 2 8 5 6 6 7 8 8 4 2...

I want to detect the duplicate element in subsets(of given size say k) of the above numbers...
For example :
Consider the increasing subsets(for example consider k=3)

Subset 1 :{1,1,2}

Subset 2 :{1,2,8}

Subset 3 :{2,8,5}

Subset 4 :{8,5,6}

Subset 5 :{5,6,6}

Subset 6 :{6,6,7}

....

....
So my algorithm should detect that subset 1,5,6 contains duplicates..

My approach : 1)Copy the 1st k elements to a temporary array(vector) 2) using #include file in C++ STL...using unique() I would determine if there's any change in size of vector..
Any other clue how to approach this problem..

答:
If they're all sets then by definition they don't contain duplicates. If they're eg. lists then you could just make sets of the sublists. In Python 2.x:

```<code>items = [1, 1, 2, 8, 5, 6, 6, 7, 8, 8, 4, 2]

for i in xrange(len(items) - 2):
    sublist = items[i:i + 3]
    if len(set(sublist)) < 3:
        print sublist, 'contains duplicates.'
    else:
        print sublist, 'contains no duplicates.'
</code>```

Result:

```<code>[1, 1, 2] contains duplicates.
[1, 2, 8] contains no duplicates.
[2, 8, 5] contains no duplicates.
[8, 5, 6] contains no duplicates.
[5, 6, 6] contains duplicates.
[6, 6, 7] contains duplicates.
[6, 7, 8] contains no duplicates.
[7, 8, 8] contains duplicates.
[8, 8, 4] contains duplicates.
[8, 4, 2] contains no duplicates.
</code>```

Body:
If they're all sets then by definition they don't contain duplicates. If they're eg. lists then you could just make sets of the sublists. In Python 2.x:

items = [1, 1, 2, 8, 5, 6, 6, 7, 8, 8, 4, 2]

for i in xrange(len(items) - 2):
    sublist = items[i:i + 3]
    if len(set(sublist)) < 3:
        print sublist, 'contains duplicates.'
    else:
        print sublist, 'contains no duplicates.'

Result:

[1, 1, 2] contains duplicates.
[1, 2, 8] contains no duplicates.
[2, 8, 5] contains no duplicates.
[8, 5, 6] contains no duplicates.
[5, 6, 6] contains duplicates.
[6, 6, 7] contains duplicates.
[6, 7, 8] contains no duplicates.
[7, 8, 8] contains duplicates.
[8, 8, 4] contains duplicates.
[8, 4, 2] contains no duplicates.


问:
Returning a mock object from a mock object
I'm trying to return an object when mocking a parser class. This is the test code using PHPUnit 3.7

```<code>    //set up the result object that I want to be returned from the call to parse method
    $parserResult= new ParserResult();
    $parserResult->setSegment('some string');

    //set up the stub Parser object
    $stubParser=$this->getMock('Parser');
    $stubParser->expects($this->any())
               ->method('parse')
               ->will($this->returnValue($parserResult));

    //injecting the stub to my client class
    $fileWriter= new FileWriter($stubParser);
    $output=$fileWriter->writeStringToFile();
</code>```

Inside my writeStringToFile() method I'm using $parserResult like this:

```<code>writeStringToFile(){
   //Some code...
    $parserResult=$parser->parse();
    $segment=$parserResult->getSegment();//that's why I set the segment in the test.
}
</code>```

Should I mock ParserResult in the first place, so that the mock returns a mock?
Is it good design for mocks to return mocks?

Is there a better approach to do this all?!

答:
I think it's a good idea to mock the smallest and closest possible set of dependencies to the class you are testing.
The idea is to reduce the test into the simplest possible scenario so it's easy to ensure the test is correct and that only tests one thing.

If you return a mock you are testing two separate things, the function that consumes the mock and the class that now creates and returns  the mock.

So test the consumer and the producer of the ParserResult separately.


答:
Take a subset, add each element into a hash table. If the hash table already contains a value - print out saying there is a duplicate.

A hash table will only allocate 1 memory block per entry. Hence its easy to find if the number already exists. Since these are just regular entries your table will be something like this:

```<code>struct Hashtable{
   int number;
};

static struct Hashtable hashTable[10];

int getHash(int x){ return x; }

void addHash(int number)
{
    if(hashTable[number].number == -1)
    { /*OK*/
        hashTable[number].number = number;
    }else{
        printf("DUPLICATE FOUND! BAILING OUT!");
    }
}

void initTable(){ for(int i = 0; i < 10; i++){hashTable[i].number = -1;}}
</code>```

Title: Detect duplicate in a subset from a set of elements

Body:
I have a set of numbers say :  1 1 2 8 5 6 6 7 8 8 4 2...

I want to detect the duplicate element in subsets(of given size say k) of the above numbers...
For example :
Consider the increasing subsets(for example consider k=3)

Subset 1 :{1,1,2}

Subset 2 :{1,2,8}

Subset 3 :{2,8,5}

Subset 4 :{8,5,6}

Subset 5 :{5,6,6}

Subset 6 :{6,6,7}

....

....
So my algorithm should detect that subset 1,5,6 contains duplicates..

My approach : 1)Copy the 1st k elements to a temporary array(vector) 2) using #include file in C++ STL...using unique() I would determine if there's any change in size of vector..
Any other clue how to approach this problem..

Body:
Take a subset, add each element into a hash table. If the hash table already contains a value - print out saying there is a duplicate.

A hash table will only allocate 1 memory block per entry. Hence its easy to find if the number already exists. Since these are just regular entries your table will be something like this:

struct Hashtable{
   int number;
};

static struct Hashtable hashTable[10];

int getHash(int x){ return x; }

void addHash(int number)
{
    if(hashTable[number].number == -1)
    { /*OK*/
        hashTable[number].number = number;
    }else{
        printf("DUPLICATE FOUND! BAILING OUT!");
    }
}

void initTable(){ for(int i = 0; i < 10; i++){hashTable[i].number = -1;}}


问:
What IDE(s) or editor(s) do companies like Google, Apple, IBM, etc. use?
Even though I have quite some experience in using various tools, I still can't make up my mind whether I prefer using IDE or a simple editor for code editing.

Most IDEs I have experienced are written in Java (like Eclipse) which makes them slow and bulky. What's good about them is that it provides lots of tools.

On the other hand editors are usually VERY fast. They can also be extended to become more similar to IDEs but usually I don't do that. However, there is Sublime Text 2 which has some basic code completion built-in.

My question would be whether most Enterprise companies like Google, Apple, IBM and etc (except Microsoft because they have AMAZING IDE which, I assume, is used by MS developers) force their workers to use IDEs and whether using plain editor with external tools is considered being not professional?

P.S. Not talking about cases like Android development where working without IDE barely possible.

答: Why should using an editor and external tools net be professional? Many programmers prefer editors like vi or emacs. Many tools can't be integrated in IDEs anyway. At least not in all use cases. Your IDE may have a terminal integrated, but when you deploy on a server you still must be able to run many tools through a SSH session or something similar. Being dependent on the IDE handling everything for you can be risky.</p>


问:
Would Using a PHP Framework Be Beneficial in My Context?
I've just started work at a small start-up company who mainly uses PHP to develop their front-end apps. I had no prior PHP experience before joining, and this has led to my apps becoming large pieces of spaghetti code. I essentially started by adding code to implement an initial feature, and then continued to hack in more code to implement further features – without much thought for the overall design.

The apps themselves output XML to render on small mobile devices.

I recently started looking into frameworks that I could use. I reckon an advantage would be that they seem to force developers to modularise their programs using good-practice design patterns. This seems great for someone in my position. The extra functions they provide, for example: interfacing with databases in such a way as to make SQL injection impossible, would be very useful too.

The downside I can see is that there will be a lot of overhead for me in terms of the time taken to learn the framework itself (while still getting to grips with PHP itself). I'm also worried that it will be overkill for the scale of the apps we develop. They tend to be programs that interface with a fairly simple back-end DB, and will generate about 5 different XML screens. Probably around 1 or 2 thousand lines of code. The time it takes just to configure the frameworks may not be worth it. The final problem I can see is that developers in the company – who have to go over my code, and who do not know the PHP framework I may use – will have a much harder time understanding it.

Given those pros and cons, I'm still not sure on what the best course of action will be; so any advice will be greatly appreciated.

答:
I think you're actually asking two questions, which I'll try to split out.

I reckon an advantage would be that they seem to force developers to
  modularise their programs using good-practice design patterns. This
  seems great for someone in my position. The extra functions they
  provide, for example: interfacing with databases in such a way as to
  make SQL injection impossible, would be very useful too.

The question is about frameworks conceptually. What you have said is absolutely true. Some frameworks encourage the use of MVC which, in my opinion, is a great way to separate the logic of your code and make it maintainable (abstract is better). There's no net worth to coupling your code to a particular database engine when you can write code once, which will work against any of the popular ones.

The downside I can see is that there will be a lot of overhead for me
  in terms of the time taken to learn the framework itself (while still
  getting to grips with PHP itself). I'm also worried that it will be
  overkill for the scale of the apps we develop.

This part is about frameworks for your project specifically. This is more difficult for me to answer, but I certainly think you should have a good strong look. Even if you only have a 1 model (one table with your data in), 5 controllers (one for each page of data that you want to manipulate) and 1 view (which just takes the data and spits it out as XML), I still think it'll be worth it. Why? Because it's a common and scalable structure. If you find that, in a few years, you end up with 50 XML pages, 50 JSON pages and 50 text pages - you'll really wish you weren't hacking away at the XML code to get it to json_encode, or toying with strip_tags because your business logic is tightly coupled with the view.

Also, once you use some of the automagic features if your framework like forms, authentication, ACL and the like, you'll never want to bore yourself by writing this yourself again. It will just take usage of one of these for you to realise that the time you spend reading the documentation is severely outweighed by the fact you barely need to test the end result compared to if you had written the feature ground-up.

The time it takes just to configure the frameworks may not be worth it.

Then pick a lightweight and almost-zero configuration framework. I've used CakePHP quite a lot, but I've heard good things about CodeIgniter too. Cake, for example, has one real file that you need to edit: database.php. Everything else is optional, and comes in a debugging mode which you can turn off later once you want to deploy your application.

The final problem I can see is that developers in the company – who
  have to go over my code, and who do not know the PHP framework I may
  use – will have a much harder time understanding it.

I wouldn't even consider this as a hurdle (that said, if you have management policies about these things then you should - I am assuming you have been given a new project with the freedom of how you want to approach it). If the developers assigned to review your code cannot get their head around a simple MVC structure, they are in no position to review code. Frameworks are very well divided: the code your write and the code they give you are in completely opposite locations (essentially). All they are really looking at for you is 3 folders: models, controllers, and views where they should be able to look at each file and see if the logic is what they'd expect.

In the long run, frameworks are the way to go. If you only want to write a script quickly that you'll only be using for a few days, then don't bother.


答:
Great answer by Jay,  I wanted to indicate that there is another possibility though.

It sounds like key things that you require from the framework are standards and structure.

I am not anti-frameworks, but you don't 'need' one,  you might benefit from one though.

You could in fact create your own MVC with very little code, and use a common DAL at the back-end (likely based on PDO   - low learning curve - or an ORM / ActiveRecord pattern).

The advantage is that you would not have to learn a framework, neither would any of your colleagues, but you would learn how to architect a simple one!  Plenty of examples on Google.  This might be a good exercise for you, as it requires you to understand the MVC (which is in fact hugely simple in concept), which in turn will help you understand the benefits, as you have thought them through in detail.

Choosing the above route may allow you to keep more of your existing source as you can consider the migration requirements.

Frameworks IMHO really come into their own when trying to maintain common standards across teams and to save you creating error prone complex common functionality.  They can be restrictive especially when migrating an existing system. So you might make this decision based on the perceived future complexity of your application, if it remains simple you don't need a framework,  if it grows,  you might wish you had you used one from the start.

Title: Would Using a PHP Framework Be Beneficial in My Context?

Body:
I've just started work at a small start-up company who mainly uses PHP to develop their front-end apps. I had no prior PHP experience before joining, and this has led to my apps becoming large pieces of spaghetti code. I essentially started by adding code to implement an initial feature, and then continued to hack in more code to implement further features – without much thought for the overall design.

The apps themselves output XML to render on small mobile devices.

I recently started looking into frameworks that I could use. I reckon an advantage would be that they seem to force developers to modularise their programs using good-practice design patterns. This seems great for someone in my position. The extra functions they provide, for example: interfacing with databases in such a way as to make SQL injection impossible, would be very useful too.

The downside I can see is that there will be a lot of overhead for me in terms of the time taken to learn the framework itself (while still getting to grips with PHP itself). I'm also worried that it will be overkill for the scale of the apps we develop. They tend to be programs that interface with a fairly simple back-end DB, and will generate about 5 different XML screens. Probably around 1 or 2 thousand lines of code. The time it takes just to configure the frameworks may not be worth it. The final problem I can see is that developers in the company – who have to go over my code, and who do not know the PHP framework I may use – will have a much harder time understanding it.

Given those pros and cons, I'm still not sure on what the best course of action will be; so any advice will be greatly appreciated.


问:
Help to understand the abstract factory pattern
I'm learning the 23 design patterns of the GoF.

I think I've found a way to understand and simplify how the Abstract Factory works but I would like to know if this is a correct assumption or if I am wrong.

What I want to know is if we can see the result of the Abstract Factory method as a matrix of possible products where there's a Product for every "Concrete Factory" x "AbstractProduct" where the Concrete Factory is a single implementation among the implementations of an AbstractFactory and an AbstractProduct is an interface among the interfaces to create Products.

Is this correct or am I missing something?

答:
Imagine that in your app you need to open a browser and it depends on the operating system. You can write:

```<code>if (operatingsystem == "win32") runExplorer();
else if (operatingsystem == "linux") runKonqueror();
</code>```

...

or, with AbstractFactory:

```<code>interface OperatingSystemAF {
   public void runBrowser();
}

class WindowsCC implements OperatingSystemAF {
  public void runBrowser() {
      //TODO run Explorer
  }
}

class LinuxCC implements OperatingSystemAF {
   public void runBrowser() {
     //TODO run Konqueror
   }
}
</code>```

and main application invokes runBrowser from OperatingSystemAF.

Body:
Imagine that in your app you need to open a browser and it depends on the operating system. You can write:

if (operatingsystem == "win32") runExplorer();
else if (operatingsystem == "linux") runKonqueror();

...

or, with AbstractFactory:

interface OperatingSystemAF {
   public void runBrowser();
}

class WindowsCC implements OperatingSystemAF {
  public void runBrowser() {
      //TODO run Explorer
  }
}

class LinuxCC implements OperatingSystemAF {
   public void runBrowser() {
     //TODO run Konqueror
   }
}

and main application invokes runBrowser from OperatingSystemAF.


问:
Is it a bad practice to write shell script with many if-else statment and for loops?
I am maintaing several data process shell scripts which are full of if-else statements and for loops . I try to make the scritps tidy and easy to debug.

When I read some suggestions about shell code best practice, it seems that is is not a best practice to have many if-else and for loop statements.

So what should I do, to write a python or c++ script instead of those logical process?

答:
There's no issue with using if- and for-statements in a shell script. Is your code deeply nested in many if/for-statements?

Don't forget that shell languages have user-defined functions should you with to make your code more modular for maintainability.


答:
It's never a good idea to have too many embedded if/else or loops, but in their own right, lots aren't inherently a bad thing.

Consider splitting out the loops unto utility functions. For example, if you have:

```<code>for stuff ..
   for stuff ...

   endfor
endfor
</code>```

It would be much better read as

```<code>findAllPricesForProducts( extractNamePriceTuple( data ) )
</code>```

with the utility functions defined appropriately. If you then document each function and give an example input/output, your code should be both readable and maintainable.

Title: Is it a bad practice to write shell script with many if-else statment and for loops?

Body:
I am maintaing several data process shell scripts which are full of if-else statements and for loops . I try to make the scritps tidy and easy to debug.

When I read some suggestions about shell code best practice, it seems that is is not a best practice to have many if-else and for loop statements.

So what should I do, to write a python or c++ script instead of those logical process?

Body:
It's never a good idea to have too many embedded if/else or loops, but in their own right, lots aren't inherently a bad thing.

Consider splitting out the loops unto utility functions. For example, if you have:

for stuff ..
   for stuff ...

   endfor
endfor

It would be much better read as

findAllPricesForProducts( extractNamePriceTuple( data ) )

with the utility functions defined appropriately. If you then document each function and give an example input/output, your code should be both readable and maintainable.


答:
In short, the abstract factory pattern is a way of encapsulating a group of factories which have a common theme. It utilizes generic interfaces to allow it to create concrete objects which are part of the common theme. Using this pattern you can interchange concrete classes without changing the code that uses them.

The Generics in C# and equivalent constructs in C/C++ or Java are very handy when creating factory pattern. Here is a comprehensive article on how to create a Generic Abstract Factory with C#.

Title: Help to understand the abstract factory pattern

Body:
I'm learning the 23 design patterns of the GoF.

I think I've found a way to understand and simplify how the Abstract Factory works but I would like to know if this is a correct assumption or if I am wrong.

What I want to know is if we can see the result of the Abstract Factory method as a matrix of possible products where there's a Product for every "Concrete Factory" x "AbstractProduct" where the Concrete Factory is a single implementation among the implementations of an AbstractFactory and an AbstractProduct is an interface among the interfaces to create Products.

Is this correct or am I missing something?


答:
I've been told (personally, no supporting link here: community wiki to invite corrections if my info is out of date) that most teams in Apple are using whatever version of Xcode is current. Those that want to do something else need to get some form of exemption.

The WebObjects (and iTunes Store, apple store etc) teams all can't use Xcode because it no longer supports Java projects. For the most part they use Eclipse with the WOLips plugin.

The kernel team are another one I know who opted out of Xcode, and they've got a make-based build system.

Title: What IDE(s) or editor(s) do companies like Google, Apple, IBM, etc. use?

Body:
Even though I have quite some experience in using various tools, I still can't make up my mind whether I prefer using IDE or a simple editor for code editing.

Most IDEs I have experienced are written in Java (like Eclipse) which makes them slow and bulky. What's good about them is that it provides lots of tools.

On the other hand editors are usually VERY fast. They can also be extended to become more similar to IDEs but usually I don't do that. However, there is Sublime Text 2 which has some basic code completion built-in.

My question would be whether most Enterprise companies like Google, Apple, IBM and etc (except Microsoft because they have AMAZING IDE which, I assume, is used by MS developers) force their workers to use IDEs and whether using plain editor with external tools is considered being not professional?

P.S. Not talking about cases like Android development where working without IDE barely possible.


问:
Taking a Projects Development to the Next Level
I have been looking for some advice for a while on how to handle a project I am working on, but to no avail. I am pretty much on my fourth iteration of improving an "application" I am working on; the first two times were in Excel, the third Time in Access, and now in Visual Studio. The field is manufacturing.

The basic idea is I am taking read-only data from a massive Sybase server, filtering it and creating much smaller tables in Access daily (using delete and append Queries) and then doing a bunch of stuff. More specifically, I use a series of queries to either combine data from multiple tables or group data in specific ways (aggregate functions), and then I place this data into a table (so I can sort and manipulate data using DAO.recordset and run multiple custom algorithms). This process is then repeated multiple times throughout the database until a set of relevant tables are created.

Many times I will create a field in a query with a value such as 1.1 so that when I append it to a table I can store information in the field from the algorithms. So as the process continues the number of fields for the tables change.

The overall application consists of 4 "back-end" databases linked together on a shared drive, with various output (either front-end access applications or Excel).

So question is: Is this a common way how data driven applications work?

Each back-end database is updated with fresh data daily and updating each takes around 10 seconds (for three) and 2 minutes(for 1).

Project Objectives: I want/am moving to SQL Server soon. Front End will be a Web Application (I know basic web-development and like the administration flexibility) and visual-studio will be IDE with c#/.NET.

Should these algorithms be run "inside the database," or using a series of C# functions on each server request. I know you're not supposed to store data in a database unless it is an actual data point, and in Access I have many columns that just hold calculations from algorithms in vba.

The truth is, I have seen multiple professional Access applications, and have never seen one that has the complexity or does even close to what mine does (for better or worse). But I know some professional software applications are 1000 times better then mine.

I have been completely on my own and need some guidance on how to approach this project the right way. What would be a good approach to follow ?

答:
In short, it will really depend on usage of the application by end-users and the requirements.

However, you may strongly benefit from two general approaches that are parts of enterprise level application development, which i have experienced so far. Namely, you may have multi-tier application with 3 layers: Presentation Layer, Business Layer and Data Layer. or as  an alternative you may have 2 layers, where you shift your Business layer to the Data Layer.

Presentation Layer: will be responsible for "User Interface Process Components"

Business layer: will be responsible for Business Components, Workflows, Entities, Service Interfaces

Data Layer: mainly responsible accessing data through Data Access Components, Service Gateways, Foundation Services (like Security, Operational Management and Communication).

As a universal truth, One diagram is worth of several description pages.

References:

There are several places where you can get some thought on how to design your application in a scale-able way. One of the reference points is Enterprise Solution Patterns Using Microsoft .NET


答:
In the two companies I have worked for(X and Y), I was allowed to use any IDE of my choice. At X, developing for iPhone was kinda restrictive as I had to use Xcode regularly. But at Y, I was allowed to use just about ANY IDE of my choice.

At times, I used to resort to writing code in Vim or Emacs(my favorite
of the two).

Most programmers writing java used JetBrains' IntelliJ IDE for java,
others liked Eclipse. Some even used Netbeans. I used IntelliJ and
Emacs.

So: it doesn't matter what IDE you use as long as you keep to their
coding standards. For Python there was nothing better than Emacs.

For C++/C I used Emacs(or VS2010), for Java I used(and still use)
Jetbrains' IntelliJ, for C# and others I use Visual Studio 2010.

For VB I use VS2010.

For HTML/css/JS I use a PLAIN text editor(Notepad++).

For Lisp I would recommend Emacs + Slime.

It depends on what you're going to code and your expertise with those editors.

ContentLicense: CC BY-SA 4.0


答:
For keeping the learning smaller - try to learn CodeIgniter (if you are on a tight time schedule to learning, choose CodeIgniter) and/or even limit to refactor the code in to proper object-orientantion and a nice class structure. I wouldn't say that your application will be magically more maintanable by a framework.

I don't know how or if you use object-oriented techniques but shouldn't it be sufficient?
Keeping the database logic (fetching/inserting/updating) in a separate class(-es) (= Model). These could be "basic" operations for data-access.

A more finished class would be all the data the specific page needs to have, combining several model-classes to a view-specific-rendering. Still it should use only code, no html!. (= viewmodel).

And having each "page" in a separate file (view), handled by a specific "viewmodel" for all the data.

This kind of behaviour is called MVVM - model-view-viewmodel - (http://en.wikipedia.org/wiki/Model_View_ViewModel).

These are small steps that will improve your site significantly if you don't already use them.


答: As this sounds like a reporting application, to simplify the database side another approach to consider is to use some of the principles of data warehousing.  This is basically denormalizing the database into into "facts" and "dimensions" (star schema).  This makes it simpler for generating reporting and handling changes of the source database (e.g. just add another dimension) and also open it up to using OLAP tools for reporting.  This could also reduce the number of databases/tables you have to worry about as they don't need to be customized.</p>

Title: Taking a Projects Development to the Next Level

Body:
I have been looking for some advice for a while on how to handle a project I am working on, but to no avail. I am pretty much on my fourth iteration of improving an "application" I am working on; the first two times were in Excel, the third Time in Access, and now in Visual Studio. The field is manufacturing.

The basic idea is I am taking read-only data from a massive Sybase server, filtering it and creating much smaller tables in Access daily (using delete and append Queries) and then doing a bunch of stuff. More specifically, I use a series of queries to either combine data from multiple tables or group data in specific ways (aggregate functions), and then I place this data into a table (so I can sort and manipulate data using DAO.recordset and run multiple custom algorithms). This process is then repeated multiple times throughout the database until a set of relevant tables are created.

Many times I will create a field in a query with a value such as 1.1 so that when I append it to a table I can store information in the field from the algorithms. So as the process continues the number of fields for the tables change.

The overall application consists of 4 "back-end" databases linked together on a shared drive, with various output (either front-end access applications or Excel).

So question is: Is this a common way how data driven applications work?

Each back-end database is updated with fresh data daily and updating each takes around 10 seconds (for three) and 2 minutes(for 1).

Project Objectives: I want/am moving to SQL Server soon. Front End will be a Web Application (I know basic web-development and like the administration flexibility) and visual-studio will be IDE with c#/.NET.

Should these algorithms be run "inside the database," or using a series of C# functions on each server request. I know you're not supposed to store data in a database unless it is an actual data point, and in Access I have many columns that just hold calculations from algorithms in vba.

The truth is, I have seen multiple professional Access applications, and have never seen one that has the complexity or does even close to what mine does (for better or worse). But I know some professional software applications are 1000 times better then mine.

I have been completely on my own and need some guidance on how to approach this project the right way. What would be a good approach to follow ?


问:
What is the correct way to implement Auth/ACL in MVC?
I am looking into making a correctly laid out MVC Auth/ACL system. I think I want the authentication of a user (and the session handling) to be separate from the ACL system. (I don't know why but this seems a good idea from the things I've read.)

What does MVC have to do with this question you ask? Because I wish for the application to be well integrated with my ACL. An example of a controller (CodeIgniter):

```<code><?php
class forums extends MX_Controller
{
    $allowed = array('users', 'admin');
    $need_login = true;

        function __construct()
        {
        //example of checking if logged in.
            if($this->auth->logged_in() && $this->auth->is_admin())
        {
            echo "you're logged in!";
        }
    }
    public function add_topic()
    {
        if($this->auth->allowed('add_topic')
        {
            //some add topic things.
        }
        else
        {
            echo 'not allowed to add topic';
        }
    }
}
?>
</code>```

My thoughts

$this->auth would be autoloaded in the system.  I would like to check the $allowed array against the user currently (not) logged in and react accordingly.

Is this a good way of doing things? I haven't seen much literature on MVC integration and Auth. I want to make things as easy as possible.

答:
My approach within Zend Framework has been to have a base class of SecureController which all controllers that require authentication must extend. In the SecureController I have a pre-dispatch authentication check for whether a user is logged in else forward to the login page.

After the login check is completed, I then carry out an authorization check whether the user can access the resource and action, the controller is usually tied to a single resource (but this behavior can be overridden) and the controller action can be mapped to a resource action.

With this in place, the only thing I need to do in each child controller is map the resource and action to what is being done without ever having to invoke the security checks again.

If I need specific ACL checks especially in view generation I can use the Zend_ACL instance that is tied to the user's session


答:
The text representation with the dashes is separating the four fields of the Guid/UUID into five groups (with the last field being separated itself after the first two bytes): Guid Text Encoding

The representation doesn't have anything to do with security, as there are different methods of computing it and is intended to be a unique identifier not necessarily a secure one.

The most likely reason the fields are split (even though the standard doesn't mention it) is for readability/separation of the component parts.

Title: Why are UUID / GUID's in the format they are?

Body:
Globally Unique Identifiers (GUID) are a grouped string with a specific format which I assume has a security reason.

A GUID is most commonly written in text as a sequence of hexadecimal
  digits separated into five groups, such as:

3F2504E0-4F89-11D3-9A0C-0305E82C3301

Why aren't GUID/UUID strings just random bytes encoded using hexadecimal of X length?

This text notation contains the following fields, separated by
  hyphens:

```<code>| Hex digits | Description
|-------------------------
| 8            | Data1
| 4            | Data2
| 4            | Data3
| 4            | Initial two bytes from Data4
| 12           | Remaining six bytes from Data4
</code>```

There are also several versions of the UUID standards.

Version 4 UUIDs are generally internally stored as a raw array of 128
  bits, and typically displayed in a format something like:

uuid:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx


问:
Is Reading the Spec Enough?
This question is centered around Scheme but really could be applied to any LISP or programming language in general.

Background

So I recently picked up Scheme again having toyed with it once or twice before. In order to solidify my understanding of the language, I found the Revised^5 Report on the Algorithmic Language Scheme and have been reading through that along with my compiler/interpreter's (Chicken Scheme) listed extensions/implementations.

Additionally, in order to see this applied I have been actively seeking out Scheme code in open source projects and such and tried to read and understand it.

This has been sufficient so far for me understanding the syntax of Scheme and I've completed almost all of the Ninety-nine Scheme problems (see here) as well as a decent number of Project Euler problems.

Question

While so far this hasn't been an issue and my solutions closely match those provided, am I missing out on a great part of Scheme?

Or to phrase my question more generally, does reading the specification of a language along with well written code in that language sufficient to learn from? Or are other resources, books, lectures, videos, blogs, etc necessary for the learning process as well.

答:
This is how I learn programming language in general:

First I check out a tutorial book NOT written by the author of the language. This gets you the view of programming the language from a perspective of the person who didn't implement the language. (This is important as you also have NOT authored the programming language in question).

THEN I pick up a book written BY the author of the programming language. For SCHEME I would suggest "SICP". This gives you a much deeper insight into the programming language and WHY it was written and the problems its used to solve by the author of the programming language.

Then I read code and specification, which is a much more detailed report on the programming language in question. Its STANDARDS and CONSTRUCTS. This should always be the last step in learning by theory.

In the meanwhile - I program and toy with the language until I feel comfortable with it. By the time you reach the third step in the "THEORY" section you will be comfortable enough to program a decently complex program using the programming language.

In short, to really master the language, there are no shortcuts.

Title: Is Reading the Spec Enough?


答: The main argument against writing complex shell scripts is that they are difficult to debug and easy to break.  That said, simply taking the same methodology into another language wouldn't be an improvement - it's pretty much inherent if what you are doing is stitching together a bunch of other programs.</p>


问:
Licensing a project
Can someone clarify the following things for me ?

Let's say I want to build a website and add publicity to it so I can make money out of my work.

I would use Html5 for the interface and C# with ASP.NET for the background programming.

I would use Visual Studio as my IDE and SQL server as a database.

This is just an example on the top of my head but I don't know where to start for the licenses.

Do I need one :

For VisualStudio and SQLServer only ?

For VisualStudio, SQLServer and pay some kind of rights for Asp.net ?

The whole package.. Both VisualStudio, SQlServer plus rights for Asp.net AND C# ?

I know this question is a little vague but I really don't know where to start and the opinion of someone with experience int this might give me just the help I need to get started.

答:
In short, once you have developed your application, there will be hosting sites that you most probably will deploy and host you web-application, and MS SQL database. Does you do NOT pay for licencing. The licencing is usually covered by the hosting services. Thus, you have to clearly understand what services are you getting in your agreement.

In regards to development tools and IDE's, you may always use Express version for FREE or buy MSDN subscription  to lower your initial application development costs related to licencing.

Title: Licensing a project


答:
If everything is fine and it's always fine then there's no problem - so introducing a new (your teams will have been following some sort of methodology - formal or otherwise) methodology would indeed be a waste of time.

Where methodologies really help though is when the team encounters problems or has problems put on them from external sources - a methodology doesn't just introduce good practices it helps you protect them. It is much easier to maintain good practices under stress when you're consciously doing them otherwise they can rapidly get squeezed out.

I don't think you necessarily need a formal methodology - but every team needs some sort of pattern (not necessarily repeating, it could be event driven) to their work to be effective IMHO.

Title: Does your team function well without following a work methodology (such as scrum)?

Body:
I've worked in a number of small teams over the last 9 years. Each had the obvious good practices, such as short meetings, revision control, continuous integration software, issue tracking and so on.

In these 9 years, I've never heard much about development methodologies; for example, there's never been a "we're doing scrum", or "lets do agile", or anything more than a passing reference. All of the teams seemed to function fine, without following much process, we were just freeflowing and just naturally worked well.

Has anyone else progressed for long periods of time without encountering scrum/agile/etc?

The only exposure I've had to these is through sites like this one. I read questions like Sprint Meetings - What to talk about ... and all the talk seems to describe almost robotic like people who follow a methodology finite state machine. Is it really (though exaggerated) like that? I wonder if the  people posting on the internet just loud supporters of "best practice", with similar textbook views, not really reflecting how people work... Or that I've encountered some teams making their processes up naturally.

Furthermore (I am in the UK, which may be relevant)... I think if a methodology were introduced to any of the teams I'd work on, they'd just reject it as being silly and unnecessary... then carry on. I'd tend to agree, following processes seems a bit unnatural. Is this typical or common?


答:
You can write .NET and T-SQL software in notepad and sell the result, same goes if you use IDEs. There are no licensing fee's for software based on the tools in .NET to create it, there may be if you try to release your software with third party assemblies that do not have free redistribution, but all the MS .NET and ASP.NET components are free to redistribute with appropriate license docs attached, not that you need to buy them.

Also you obviously need buy licenses for any tools if you want to use them, like hosting it yourself using mssql means you need the license for the server you're running, but you don't need another license to sell the database file from your app.

Title: Licensing a project

Body:
Can someone clarify the following things for me ?

Let's say I want to build a website and add publicity to it so I can make money out of my work.

I would use Html5 for the interface and C# with ASP.NET for the background programming.

I would use Visual Studio as my IDE and SQL server as a database.

This is just an example on the top of my head but I don't know where to start for the licenses.

Do I need one :

For VisualStudio and SQLServer only ?

For VisualStudio, SQLServer and pay some kind of rights for Asp.net ?

The whole package.. Both VisualStudio, SQlServer plus rights for Asp.net AND C# ?

I know this question is a little vague but I really don't know where to start and the opinion of someone with experience int this might give me just the help I need to get started.


问:
Arranging the colors on the board in the most pleasing form
Given a rectangular board of height H and width W.

N colors are given and each color occupies Xi percentage of area on the board.

Sum of Xi's is 1.

The colors on the board must be placed in rectangles.

An optimal solution has the rectangles' aspect ratios as close to 1 as possible.

An ideal case has the board filled only with squares.

What's the best algorithm for laying out the rectangles?

答:
You could do it like this:

find the largest square place in the board

place a square of the largest colour left to place in there, subtract this Pi by the appropriate amount

repeat

Your question, however, is far from complete and unambiguous
If you want to only have one rectangle per colour, things can get a bit more complicated.
(brute force, not very elegant)

Factor all the areas for the colours into their prime factors, and get all possible two-element factorizations that will fit within the board. For most numbers up to reasonable amounts, this will be relatively manageable (if not, you could just scale down a factor ten, the visual result won't differ much).

for each possible combination of these two-element factorizations, try to fit them into the board (most will not succeed)

find the one with best ratios, weighted however you want

I can imagine a lot better approaches exist, but these might do the trick if your board is not too large, and the amount of colours is reasonable


问:
Validation and Error Generation when using the Data Mapper Pattern
I am working on saving state of an object to a database using the data mapper pattern, but I am looking for suggestions/guidance on the validation and error message generation step (step 4 below). Here are the general steps as I see them for doing this:

(1) The data mapper is used to get current info (assoc array) about the object

in db:

```<code>+=====================================================+
|  person_id  |   name   |   favorite_color   |  age  |
+=====================================================+
|   1         |   Andy   |   Green            |  24   |
+-----------------------------------------------------+
</code>```

mapper returns associative array, eg. Person_Mapper::getPersonById($id) :

```<code>$person_row = array(
    'person_id' => 1,
    'name' => 'Andy',
    'favorite_color' => 'Green',
    'age' => '24',
);
</code>```

(2) the Person object constructor takes this array as an argument, populating its fields.

```<code>class Person {

    protected $person_id;
    protected $name;
    protected $favorite_color;
    protected $age;

    function __construct(array $person_row)
    {
        $this->person_id = $person_row['person_id'];
        $this->name = $person_row['name'];
        $this->favorite_color = $person_row['favorite_color'];
        $this->age = $person_row['age'];
    }

    // getters and setters...

    public function toArray()
    {
        return array(
            'person_id' => $this->person_id,
            'name' => $this->name,
            'favorite_color' => $this->favorite_color,
            'age' => $this->age,
        );
    }
}
</code>```

(3a) (GET request) Inputs of an HTML form that is used to change info about the person is populated using Person::getters

```<code><form>
    <input type="text" name="name" value="<?=$person->getName()?>" />
    <input type="text" name="favorite_color" value="<?=$person->getFavColor()?>" />
    <input type="text" name="age" value="<?=$person->getAge()?>" />
</form>
</code>```

(3b) (POST request) Person object is altered with the POST data using Person::setters

```<code>$person->setName($_POST['name']);
$person->setFavColor($_POST['favorite_color']);
$person->setAge($_POST['age']);
</code>```

*(4) Validation and error message generation on a per-field basis

    - Should this take place in the person object or the person mapper object?

    - Should data be validated BEFORE being placed into fields of the person object?

(5) Data mapper saves the person object (updates row in the database):

```<code>$person_mapper->savePerson($person);
// the savePerson method uses $person->toArray()
// to get data in a more digestible format for the
// db gateway used by person_mapper
</code>```

Any guidance, suggestions, criticism, or name-calling would be greatly appreciated.

答:
I think you should define in the person object — and not in the mapping object — the validation logic.

You get the POST data and assign it to the person object, and if there is any error, it should happen there, before you reach the mappign step. In fact, you should never call savePerson() when the data provided is not correct.

OwnerDisplayName: AndyPerlitch

OwnerDisplayName: Gallaecio


问:
Prerequisites to compiler theory?
It's not meant to be subjective or get advice on what would be the best path to take, but an objective list of things that must be known in order for me to pick up a book on compiler theory and understand it.

What level of mathematics, and related skills are required?

答:
The key question really is: at what level? I'm going to assuming a fairly introductory one if you're asking this question. I have only done one course on compilers, so perhaps my knowledge is too elementary, but here's what is useful to know:

Basic 32-bit assembler, including how the stack works, and the usage of ebp, and the different kind of jmps

Good understanding of data structures: trees, linked lists, and some of the common algorithms associated with them (binary search, for example)

Basic understanding of complexity theory, mainly the big O notation

Knowledge of basic regular expressions

To be perfectly honest, if you wanted to pick up any book on compiler theory and read it, then you should have read an introduction to compilers and preferably implemented something basic yourself (so you get a good idea from how it works: parsing source code, generating parse trees, to code generation). After that, you can look at optimisations (e.g. age = 4 + 5 would be compiled directly as age = 9, the 4+5 computation would be done once at compile time and never again).

Title: Prerequisites to compiler theory?


问:
MVC and delegation
I am a beginning iOS programmer and use the Model-View-Controller model as a design pattern: my model doesn't know anything about my view (in order to make it compatible with any view), my view doesn't know anything about my model so they interact via my controller. A very usual way for a view to interact with the controller is through delegation: when the user interacts with the app, my view will notify my controller, which can call some methods of my model and update my view, if necessary.

However, would it make sense to also make my controller the delegate of my model? I'm not convinced this is the way to go. It could be handy for my model to notify my controller of some process being finished, for example, or to ask for extra input of the user if it doesn't have enough information to complete the task. The downside of this, though, is that my controller would be the delegate for both my controller and my model, so there wouldn't be really a proper way to notify my model of changes in my view, and vice versa. (correct me if I'm wrong.)

Conclusion: I don't really think it's a good idea to to have my controller to be the delegate of my model, but just being the delegate of my view would be fine. Is this the way most MVC models handle? Or is there a way to have the controller be the delegate of both the controller and the model, with proper communication between them?

Like I said, I'm a beginner, so I want to do such stuff the right way immediately, rather than spending loads of hours on models that won't work anyway. :)

答:
I'll speak specifically to iOS as it has its own concepts and some language features make its way of doing things a good fit. Often in iOS the Controller - Model layer interactions are based on some variant of Observer pattern (key-value observing (KVO) but also NSNotification). I find the model layer often doesn't engage in the same type of interactive back and forth that happens in the View - Controller layer interface (think the complexity of a dynamic, fully-featured table view), so delegation is not the most natural fit. Usually something (user input, a network request, etc) changes the model, and the controller responds accordingly by updating the view. But delegation is still used in long-running, dynamic interactions such as a table view that displays the contents of a frequently updating data set (see NSFetchedResultsController).

As to your question of having the controller be the delegate of your view and your model, there's no inherent problem other than you'll degrade the cohesion of your controller, and it sometimes becomes a good choice to split the controller layer into view controllers and data controllers. Using KVO or NSNotification to observe changes in the model layer is usually straightforward enough that you won't find a pressing need to extract a new class.

Title: MVC and delegation


答:
There is no licensing fee for Visual Studio - either use the Express version, or buy one of the commercial versions. The usage of the code you write with VS is irrelevant.

There is no licensing fee for C# or ASP.NET.

If you use an edition of SQL Server other than SQL Server Express, that costs money.

The Windows OS on your server costs money.

However, if you are renting hosting, the SQL Server and Windows licensing is a matter for the hosting company, they buy SQL Server and Windows, and incorporate that into what they charge you for hosting.

So unless you are hosting on your own hardware setup, and just renting rack space, you really don't have any licensing issues to worry about.

Title: Licensing a project