问:
How to check any undocumented methods provided by apple?
The following tools is provided by Apple

dlopen

dlsym

objc_getClass

sel_registerName

objc_msgSend

Those are listing Objective-C selectors, or strings. Objective-C selectors are stored in a special region of the binary, and therefore Apple could extract the content from there, and check if you've used some undocumented Objective-C methods.

How to utilize these tools to find undocumented Objective-C methods?

EDIT:
Recently, one of my App rejected due to using one undocumented methods.

-[UIDevice setOrientation]

Since, selectors are independent from the class you're messaging, even if my custom class defines -setOrientation: irrelevant to UIDevice, there will be a possbility of being rejected.

答:
You don't have to look very hard in the Objective-C Runtime Reference to figure out how to do things like get a list of all the registered classes, get all the methods for a given class, etc. From that you can generate a list of all methods. The runtime doesn't care about which methods are documented, though, so in order to pick out the undocumented methods you'd also need to build a list of the documented methods, perhaps by scanning through the header files, and then compare the two lists.

I could see how all that might be useful if you wanted to build a tool that would warn you if you used an undocumented method in your own code. But then, if you don't go snooping around in the runtime, the chance that might use an undocumented method in your code by accident is pretty small, so I'm not sure it's worth all the bother.

Since, selectors are independent from the class you're messaging, even
  if my custom class defines -setOrientation: irrelevant to UIDevice,
  there will be a possbility of being rejected.

There's no prohibition on using methods with the same names as undocumented methods of Apple-supplied classes. What you're not allowed to do is to call undocumented methods of Apple-supplied classes. The reason your app was rejected, presumably, was that you sent -setOrientation: to an instance of UIDevice. If you had instead sent that message to a class of your own creation, I don't believe you'd have been rejected. I don't have any inside knowledge, but I feel reasonably certain that Apple doesn't detect the use of undocumented methods by simply listing the selectors used in your app.


问:
Drop in service for account management, authentication, identity?
I'm building an Android app and associated set of web services for uploading/downloading data. I need a basic (no frills) solution for account management (register, login, logout, verify credentials/token).

What open source / third party solutions exist for this scenario?

I need:

create a new account db based on a salt

simple web service to create a new account

simple web service to authenticate supplied credentials and return some sort of token

That's it, I can get by without 'fancy' email activation or  password reset for the time being.

And then moving beyond simple account management, I will need some sort of 'token' based authentication for a web service.

Are there off-the-shelf components for this? Should I just use a 'blank' django or rails app to get this done? Seems crazy for everyone to be doing CREATE TABLE user_accounts ...

Thoughts?

Thank you.

答:
For lack of more specific requirements, I would start by picking a modern web stack you had some familiarity with and riding it's built-in authentication back-end. You might need to roll a few services in front of it to manage some angles but you should be able to avoid crafting a real secured user management system.

Also keep in mind that while http basic auth isn't the perfect answer, http basic auth over ssl is a reasonable alternative until you've got something worth stealing.

ContentLicense: CC BY-SA 3.0


问:
How to run any cronjobs using Objective-C at iOS Platform
Is there any way to run schedulers / schedule programs for example Cron Jobs using  Objective-C at iOS Platform?

I need to create a schedule update to my ios, lets say for example every five days my app will fetch something to the internet and update the database I also want user to set the interval.

I think for this purpose cron jobs can be a vital part. Is there any suggestions or other ways?

答:
There is no access to cron in iOS. In fact, iOS generally cuts down the ability to have your app stay running in the background -- user battery life is more important than developer convenience.

A poor man's approach would be to use CoreData to record a timestamp of last update, then check when the app is opened, and periodically while the app is running, if there should be a data update. If there are updates that come out while the user is not using the app you might want to look at push notifications and running something server-side.


问:
Why is nesting or piggybacking errors within errors bad in general?
Why is nesting or piggybacking errors within errors bad in general?

To me it seems bad intuitively, but I'm suspicious in that I cannot adequately articulate why it is bad.  This may be because it is not in general bad and that it is only bad in specific instances.  Why is it detrimental to design error/exception handling in such a way.

The specific instance is that of a REST service.  There is a desire by some to use http errors (specifically the 500 response) as a way to indicate any problem with specific instances of a resource.  An example of an instance resource in this case would be:

```
  http://server/ticket/80 # instance
  http://server/ticket # not an instance
```

So this is the behavior that is being proposed.

If ticket 80 does not exist return a http response code of 500.  Within the body of the error return the "real" error as an additional error code and description.

If the ticket resource doesn't exist return a response code of 404.

答:
The problem with piggy-backing errors is that when it occurs, you don't know which of the potential errors is the real problem.

In your case, returning an http error code of 500 could mean:

the ticket doesn't exist

there's a problem accessing ticket #80

there's a problem in recalling and populating ticket #80 with information

In general, a piggy-back technique is lazy.  Lazy can be good, but lazy can also be really bad.  In this case, I'm voting for the latter.

This one is lazy bad because when (not if) that error occurs, you'll have to do double or triple the amount of work in figuring out what really went wrong.  On a small enough system, that might be tolerable.  In a high volume or marginally stable environment, the lazy approach is a good recipe for a serious headache.

The right approach is to code up an error page that indicates

something went wrong

the system proactively detected something went wrong (which is not the same as the first item)

diagnostic information has been sent to a sysad account or present the diagnostic information to be provided in the trouble call.

If you were really hard up for development time then at least use a much lesser used http error code so you can bypass some of the which-error-was-it troubleshooting.


问:
Dependency injection and IOC containers in a closed project
Does it make sense to assemble my project with dependency injection containers if I am the only one who will use the code of that project?

The question came up when I read this IOC Article http://martinfowler.com/articles/injection.html

The justification for using dependency injection in this article is that friends can reuse a class, and replace depending classes with their own classes because they get injected and not instantiated in the class.

I would only use it to inject objects where they are needed instead of passing them through layers to their target. (Which is not so bad I learned here: Is it bad practice to pass instances through several layers?)

(Maybe I will reuse parts of the project, who knows, but I don´t know if that is a good justification)

答: To me DI is a good way to keep classes simple and with a single responsability. Also, when you (unit) test them you'll thank their dependencies (probably mocks) are easily injectable.</p>


问:
Techniques to increase logic at programming
I am into programming since last 3 years. But I seems to be lost in it. I am not able to get good at it even though I code everyday.

suppose I solve one problem, I will wander from solution to solution and implement some other solution. I cant focus much. I get many defects for the code I write. I afraid of code I dont know why if I dont finish it on time my boss will fire me etc. I enjoy coding but not all the time. How to increase patience?

I always wonder how do I become the best coder like many exceptional programmers. I know this sounds subjective but I think this will help programmer community to get good at it especially for average like me or beginner programmers.

答:
I've had this kind of problem before.. It happened right before I burned out and couldn't program at a productive level for nearly a year afterwards(and I was only 19 at the time).

Anyway, Looking back on it, the issue I had was lack of direction and management. I'd work on implementing something for a month or two and then when it was nearly done, suddenly it needs to be done in a completely different manner. This was a huge blow to my self-esteem as I'm quite proud of every line of code I write. Also the management consisted mostly of a couple of hours discussion how something should work and then a couple of days of not discussing anything. Some of this was my fault as well of course. This was also compounded by the fact that at some point the work got extremely tedious and I felt like I was just typing code and not actually being creative at all.

General guidelines:

If you feel like there is a lack of direction, bring it up. Ask your superior for more structure in where things are going

If you're having to delete code all of the time(and not in a good way like refactoring), seriously question why there isn't a more complete plan constructed before implementing

If you're in a super small start up and functioning as a "lead" developer, when you're clearly not experienced for it, swallow your pride and tell your manager you're really more of a junior developer.

Tedium is usually brought about by the appearance of no work getting done. Take your tasks in smaller bites and keep track of your progress. This will help to feel that you're getting something done

If all else fails, you may want to start applying elsewhere, especially if your manager doesn't seem to care that you may be heading for a burnout


答:
It looks like you're transferring a JPEG/Exif image.  You need to look at your "recovered" file and find the Start Of Image (SOI) marker, which is DBFF.  Once you have this, you can match that up to the start of your original file and go from there.  It looks like the first part of the image transferred OK (about half of the first "line"), maybe see how that maps to your block size and see if you've gotten some garbage or padding somewhere along the line.

I'd suggest leaving the image transfers for the moment and create your own data file with some known data in it (a block of bytes with values from 00 to FF, followed by a block of 16-bit ints with values from 0000 to 1000, followed by a block of 32-bit ints if you want to go that far).  Then transfer that and see how it turns out.  It should be easier to spot patterns in sequential data.  Once you can get your test data transferred correctly, try again with your image.

Title: Reconstruct a file from a TCP stream

Body:
I have a client and a server and a third box which sees all packets from the server to the client (but not the other way around). Now when the client requests a file from the server (over HTTP), the third box sees the response. I am trying to reconstruct the file there. I am using libpcap to capture TCP datagrams and trying to reconstruct the file there. Here is what I did

Listen for packets on an interface

Group all packets which have the same ACK number

Sort the group based on SEQ number

Extract data from each packet and combine them and write to the disk

The problem is, the file thus generated is not exactly the same as the original file. Their sizes are the same each, but when I open the images in an image viewer, they look different. time Does everything sound correct here?

EDIT

Hexdump of first 512 bytes of the recovered file

```<code>0000000 009a 0095 0090 008b 0086 0081 007c 0077
0000010 0072 006d 0068 0063 005e 0059 0054 004f
0000020 004a 0045 0040 003b 0037 0032 002d 0028
0000030 0023 001e 0019 0014 000f 000a 0005 0000
0000040 0400 0000 0000 0000 7276 6375 5420 4352
0000050 0000 0000 6720 7369 0000 0000 0000 0000
0000060 0000 0000 0002 0000 028f 0000 0000 0000
0000070 0001 0000 0000 0000 6173 6d65 1fe7 0057
0000080 0000 0050 0956 004c 0000 0000 5a20 5859
0000090 0001 0000 5c9e 0003 130b 0004 edcc 0003
00000a0 cf14 0010 5f2e 0014 a4fe 0013 0000 0000
00000b0 6577 7669 0000 0000 0000 0000 0000 0000
00000c0 0000 0000 0000 0000 0000 0000 2e31 2d32
00000d0 3636 3139 4336 4945 6e20 2069 6f6e 7469
00000e0 6469 6f6e 2043 6e67 7769 6965 2056 6365
00000f0 656e 6572 6566 2c52 0000 0000 0000 0000
0000100 0000 3100 322e 362d 3936 3631 4543 2049
0000110 696e 6e20 696f 6974 6e64 436f 6720 696e
0000120 6577 5669 6520 6e63 7265 6665 5265 002c
0000130 0000 0000 0000 7363 6465 0000 0000 0000
0000140 0000 0000 0000 0000 0000 0000 0000 0000
0000150 4742 7352 2d20 6520 6163 7370 7220 6f75
0000160 6f6c 2063 4742 2052 6c74 6175 6566 2044
0000170 2e31 2d32 3636 3139 2036 4543 2e49 0000
0000180 0000 0000 0000 0000 4200 5247 2073 202d
0000190 6365 7061 2073 7572 6c6f 636f 4220 5247
00001a0 7420 756c 6661 4465 3120 322e 362d 3936
00001b0 3631 4320 4945 002e 0000 0000 0000 7363
00001c0 6465 0000 0000 0000 0000 0000 0000 0000
00001d0 0000 0000 0000 0000 0000 0000 0000 0000
*
00001f0 6368 632e 6965 772e 7777 2f2f 703a 7474
0000200
</code>```

Hexdump of first 512 bytes of the original file:

```<code>0000000 d8ff e0ff 1000 464a 4649 0100 0101 2c01
0000010 2c01 0000 e2ff 6d1c 4349 5f43 5250 464f
0000020 4c49 0045 0101 0000 5d1c 694c 6f6e 1002
0000030 0000 6e6d 7274 4752 2042 5958 205a ce07
0000040 0200 0900 0600 3100 0000 6361 7073 534d
0000050 5446 0000 0000 4549 2043 5273 4247 0000
0000060 0000 0000 0000 0000 0000 0000 d6f6 0100
0000070 0000 0000 2dd3 5048 2020 0000 0000 0000
0000080 0000 0000 0000 0000 0000 0000 0000 0000
*
00000a0 0000 0000 0000 0000 1100 7063 7472 0000
00000b0 5001 0000 3300 6564 6373 0000 8301 0000
00000c0 6c00 7477 7470 0000 ef01 0000 1400 6b62
00000d0 7470 0000 0302 0000 1400 5872 5a59 0000
00000e0 1702 0000 1400 5867 5a59 0000 2b02 0000
00000f0 1400 5862 5a59 0000 3f02 0000 1400 6d64
0000100 646e 0000 5302 0000 7000 6d64 6464 0000
0000110 c302 0000 8800 7576 6465 0000 4b03 0000
0000120 8600 6976 7765 0000 d103 0000 2400 756c
0000130 696d 0000 f503 0000 1400 656d 7361 0000
0000140 0904 0000 2400 6574 6863 0000 2d04 0000
0000150 0c00 5472 4352 0000 3904 0000 0c08 5467
0000160 4352 0000 450c 0000 0c08 5462 4352 0000
0000170 5114 0000 0c08 6574 7478 0000 0000 6f43
0000180 7970 6972 6867 2074 6328 2029 3931 3839
0000190 4820 7765 656c 7474 502d 6361 616b 6472
00001a0 4320 6d6f 6170 796e 6400 7365 0063 0000
00001b0 0000 0000 7312 4752 2042 4549 3643 3931
00001c0 3636 322d 312e 0000 0000 0000 0000 0000
00001d0 1200 5273 4247 4920 4345 3136 3639 2d36
00001e0 2e32 0031 0000 0000 0000 0000 0000 0000
00001f0 0000 0000 0000 0000 0000 0000 0000 0000
0000200
</code>```

Some more details:

I am using C++

The packet data is being stored as std::vector<char>

I did change the byte order while reading the ack number and seq number from the packet using ntohl

I am not sure if I need to change the byte order for the data as well. I tried to reverse the data from each packet before combining them, even that did not work.

Is there something I am missing?

EDIT

Original file:

Recovered file:


问:
How to organise projects with dependencies on BitBucket?
Both Mercurial and BitBucket make one fundamental assumption: 1 repo = 1 project.

If I have a project that has a dependency (a library) which is shared by many projects, this assumption gets in the way. Now it is no longer possible to have a separate BitBucket page for each project while still being able to commit atomic revisions to multiple projects.

If I put all the projects into one repo, they all become one “project” on BitBucket. If I put them in separate repos, it is no longer possible to know which version of the library project was in use at revision X of a dependent project.

How is this situation normally solved on BitBucket, or is there explicitly no support for this common scenario?

答:
git has submodules

looks like hg has subrepository


问:
What is the motivation behind TypeScript?
We had JavaScript, then we had Flash, then we had Silverlight and then HTML5 ownd them all.

So what is the motivation behind TypeScript? What problems are going to be tackled and what improvements do we get with TypeScript?

http://www.typescriptlang.org/

答:
Looks to me like it's a statically-typed, class-based language that compiles down to JavaScript.  It's a good idea, and one that others have had as well.

The advantages should be obvious to anyone who's developed in both statically-typed, class-based languages and in JavaScript:

First and foremost, a compiler.  Being able to check for obvious correctness problems caused by typos or carelessness prior to deployment is something that most developers take for granted until they have to do web development, and then it's suddenly yanked out from under their feet. Browsers are designed to make the browsing experience pleasant at the expense of proper testing and debugging facilities, and the standard solution, JSLint, is no substitute for a real compiler as it misses some obvious correctness problems and mixes a bunch of style-checker complaints in with its reports. Having a real compiler is a huge step forward.

And along similar lines, a type system.  Type systems improve your code by making it easier to read (you know exactly what's being passed into a function, and what it can do, just by looking at the parameter list, for example,) and by enforcing a certain degree of correctness at compile time. (If you're expecting a specific object type, passing an integer is an error. JavaScript will let you do that and then it blows up when you try to run it; a compiler with a type system will catch it and report an error for you.)

So as we see, the basic idea is a very good one.  Having said that, I can't say anything about the language itself because I have no experience with it.  But I've used Smart (linked to above) and found it to be an incredibly powerful and useful tool for web development.

OwnerDisplayName: Gero


答:
Both Mercurial and BitBucket make one fundamental assumption: 1 repo = 1 project.

I think you are wrong, at least about the Mercurial part. I have multiple projects inside the same Mercurial repository and it works very well for me (and for many others).

As for BitBucket, it is built around the concept of repositories and it doesn't go much further than that. It provides a basic wiki and bug tracker, but it is not a project management tool. If you need a separate wiki page per project, you should consider using an external wiki or project management tool.

Title: How to organise projects with dependencies on BitBucket?

Body:
Both Mercurial and BitBucket make one fundamental assumption: 1 repo = 1 project.

If I have a project that has a dependency (a library) which is shared by many projects, this assumption gets in the way. Now it is no longer possible to have a separate BitBucket page for each project while still being able to commit atomic revisions to multiple projects.

If I put all the projects into one repo, they all become one “project” on BitBucket. If I put them in separate repos, it is no longer possible to know which version of the library project was in use at revision X of a dependent project.

How is this situation normally solved on BitBucket, or is there explicitly no support for this common scenario?


答:
I think it's a effort to turn a shared, unreliable piece of crap (javascript) into a proprietary language that can actually be used for substantial projects.

It ought to be compared to GWT, which has a similar set of goals but took a cleaner approach by making javascript not part of the language; and with Java applets or Flash, which take the very clean approach of defining a complete runtime environment independent of the browser.

Your opinion may vary, but I think it's doomed as long as it depends on the browsers
natively supplying the (varying, inconsistent) javascript implementations and DOM models.

Title: What is the motivation behind TypeScript?

Body:
We had JavaScript, then we had Flash, then we had Silverlight and then HTML5 ownd them all.

So what is the motivation behind TypeScript? What problems are going to be tackled and what improvements do we get with TypeScript?

http://www.typescriptlang.org/


问:
Scrum - real life example?
I'm starting with scrum and saw many partial examples on books and tutorials, but when try to use scrum in the real life, it's not easy to write the user stories and create the product backlog. I want to see a real project with user stories, product backlog and sprint backlogs to see if I'm doing it in the correct way.

Is there any open source project with a public product backlog ?
Is there any shared complete user stories and product backlog from a real project?

答:
Theres two ways to do this - like everything the easy way and the hard way. The easy way would be to get someone with experience involved, a mentor / consultant / trainer etc, have them learn your work situation and provide the advise you need. The hard way is to read a book, then jump in a do it, get some of it right, make some mistakes, recognize and learn from them, and refine things next time around (sounds like you could use Scrum to learn Scrum).

I'm a hard way kind of guy - all you can do is back yourself, accept you won't get it right first time, but will learn nothing from not starting, and get on with it. You will probably learn numerous bad habits on long the way, so where possible use a mentor (and Q/A sites like this) - and be open to criticism and self criticism.

Referring to the OP - it's not easy to write user stories - you are correct - it's not easy, if it was, then Scrum would not be around and waterfall would be just fine. No one claimed scrum makes it easy (at least, no one who knows what they are talking about). Software development is hard, Scrum is a a way to manage the hardness, maybe making it easier or as easy as possible through better management. Scrum cannot make things "easy".

Title: Scrum - real life example?


问:
How do you get a client to understand the importance of a project lifecycle?
Situation is I have a number of in-house clients who continue to have trouble grasping the concept of defining clear requirements for a project and committing to them. Unfortunately my job situation is that I can't decline such projects, and I am often forced into situations that I can tell are doomed to scope creep (or worse) from the very start. Telling them that detailed requirements are vital and why we need them (using examples of past troubled projects due to this) have not helped.

I am looking for techniques, tips, words, etc that you might use to motivate or illuminate clients in such situations to the necessity of requirements,setting milestones, etc.

I am only a developer, and not a manager.

答: Here's a tip that usually works - if in the middle of the implementation they come up with "yet another feature", you should put on a straight face and require that contract, delivery date, payment be updated to reflect the new feature "cost of implementation". After a few of these, you should be noticing a sharp decline in a number of feature creeps.</p>

ContentLicense: CC BY-SA 2.5


答:
Mercurial has the Subrepositories feature which essentially do configuration management of your other repositories. It is extremely easy to setup.

All you have to do is create the .hgsub file like this:

```<code>src/app         = https://bitbucket.org/<user>/app
src/framework   = https://bitbucket.org/<user>/framework
src/library     = https://bitbucket.org/<user>/library
</code>```

One repo per line, path to the left, URL to the right. When you commit, Mercurial will fetch those repositories and prompt you for credentials. After that, and each time you commit, the .hgsubstate file will change automatically depending on the states of your subrepos (revision, branch, or whatever you have selected in each one).

```<code>27442cb5903128c6f817e2943030b9297a0d569f src/app
4d11fabc8a6121ceb07e11ddd81fb1e4ad2f5980 src/framework
8d6f570174a535839c189cf84d04f5ae5253a253 src/library
</code>```

The left side represents the hash, the right side the path to the repo. This file is versioned, but as I mentioned earlier, it gets edited automatically by mercurial.

So if you make a commit on src/app, the hash is going to change. When you are happy with the combination of states in each subrepo you commit the parent repo. *BLAM!*, you have configuration management.

Edit: I just discovered the Hg Guest Repo extension and I think this is just what you need, quoting:

```<code>Extension for enterprises needing to handle modules and components

Hg subrepos do not handle the sharing of components well, due to
the recursive merge from the top (super) repo and requirement to
lock at a specific version.

Guestrepo's goal is to overcome these limitations.

The guestrepo extension does not change any existing Mercurial
 behavior. It only adds new commands.
</code>```

Body:
Mercurial has the Subrepositories feature which essentially do configuration management of your other repositories. It is extremely easy to setup.

All you have to do is create the .hgsub file like this:

src/app         = https://bitbucket.org/<user>/app
src/framework   = https://bitbucket.org/<user>/framework
src/library     = https://bitbucket.org/<user>/library

One repo per line, path to the left, URL to the right. When you commit, Mercurial will fetch those repositories and prompt you for credentials. After that, and each time you commit, the .hgsubstate file will change automatically depending on the states of your subrepos (revision, branch, or whatever you have selected in each one).

27442cb5903128c6f817e2943030b9297a0d569f src/app
4d11fabc8a6121ceb07e11ddd81fb1e4ad2f5980 src/framework
8d6f570174a535839c189cf84d04f5ae5253a253 src/library

The left side represents the hash, the right side the path to the repo. This file is versioned, but as I mentioned earlier, it gets edited automatically by mercurial.

So if you make a commit on src/app, the hash is going to change. When you are happy with the combination of states in each subrepo you commit the parent repo. *BLAM!*, you have configuration management.

Edit: I just discovered the Hg Guest Repo extension and I think this is just what you need, quoting:

Extension for enterprises needing to handle modules and components

Hg subrepos do not handle the sharing of components well, due to
the recursive merge from the top (super) repo and requirement to
lock at a specific version.

Guestrepo's goal is to overcome these limitations.

The guestrepo extension does not change any existing Mercurial
 behavior. It only adds new commands.


问:
How to Be a Software Engineer?
My problem is kind of weird so please bear with me.

I have been working in a start up concerned basically with mobile development since my graduation 2 years ago. I develop apps for iOS but it's not really relevant. The start up structure is simply founders > developers, with no middle-tier technical supervision or project management whatsoever.

A typical project cycle of ours is like this: meet with a client > send very vague requirements to an outsourced graphics designer > dig in development right after we get the design, no questions asked > then improvise improvise improvise! It's not that we are unaware that stuff like requirements analysis, UML, design patterns, source code control, testing, development methodologies... etc. exist, we just simply don't use them, and I mean like never.

The result is usually a clunk of hardly-maintainable yet working code. Despite everything we are literally flourishing with many successful apps on all platforms and bigger clients each project. The thing is, we want the chaos to stop and we're looking for advice.

How would you fix our company technically? Given that you can't hire project managers or team leaders just because we are barely 5 developers, so it wouldn't be a justified cost for the founders, but one-time things like courses, books, private training... etc is an option. Lastly, if it's relevant, we are based in Egypt.

Thank you a lot in advance.

答:
I don't think your problem is weird.  It is very common and is one of many causes for failure of up to 95% of start up companies fail (and also many non-start ups).  You mentioned that you graduated two years ago but did not identify the degree.  If it was computer science, some people would already say you are a software engineer.

Software Engineering Institute (SEI), with funding from US Department of Defense, created a scale and batteries of assessments called the Capability Maturity Model (CMM) to measure the level of preparation to succeed in software development contracts from the government and others.  They characterize maturity by level, where level 1 is called Initial or Chaotic because software development is undocumented, ad-hoc, uncontrolled and reactive.  The raw skill of someone involved in the project is the main thing holding things together to create a deliverable for the customer.  Most of us have been on a lot of level 1 projects where hard work and smart people saved (or almost saved) the day.

Original CMM recommended progressing up the levels in sequence.  Level 2 called repeatable was all about management related processes.  Level 3 called defined, was about team practices defined by management for developers.  There were five layers (4 is Managed, 5 is Optimizing) and spread among the layers were many Key Process Areas (KPAs) that organizations were expected to learn and practice.

A revised model, CMMi (CMM integration), identifies similar layers, and discusses core process areas.  It has the same kind of level oriented progression called staged, and a road map oriented progression called continuous.  With continuous, it is possible to select core processes that are most valuable to the organization, and to emphasize them to the exclusion of other processes.

Certification for CMMi is an expensive business, and the documentation is huge and daunting.  Understanding some of its concepts can be valuable, but mostly in answer to your question "How to be a Software Engineer?"

Your other question about how to fix the company technically is related, but needs more concrete suggestions.

Understand the concepts behind software life cycle models (waterfall, spiral, feature oriented, and most importantly iterative/incremental).  Somewhere during development you should do not only code, but also analysis, design, and testing.  For agile, this can be making story cards or use cases with alternative flows, creating unit tests, and writing code, often a feature at a time.

Insure that each project is scoped at a reasonable size for your team (requirements management).

Create plans and track progress with a flexible tool like Atlassian Jira or something similar that will create a database of tasks among the team (integrated planning and tracking).

Have a quality assurance strategy that runs the full duration of the project.  Test Driven Development (TDD) may supply much of this requirement, but you should also read about the V-Model.

The code you write should follow some rules, so you should create or adopt coding standards appropriate to your development language.  Having these rules will boost code quality and provide a guide for peer review of code.

Utilize some kind of peer review where members of the team look at each others work for defects and recommend corrections and improvements.  This is a key teaching and learning opportunity, so don't dismiss it as too expensive.

Code and documentation assets of the project need to be source controlled, version numbered, and described by change logs and release notes.

This is certainly a partial list, and others will suggest other very helpful additions.  Everyone in the team needs to be thoroughly trained to understand and use each of these, but you may see benefits as you progress.  Open source tool support is available for most, so if the first option in a category is too expensive, look around and ask around for some options that fit you better.

Title: How to Be a Software Engineer?


答:
It is certainly a paradigm shift. It will take some time to understand, adjust the mind set for any team to be effective with Scrum approach/process.

There is no short way or silver bullet that will direct you to the most accurate scrum management of the project; where user stories are gathered and backlog items are created. However, as it is an iterative approach, by looking at good samples, learning and using Scrum ceremonies "the team" may get into the most beneficial/suitable approach that fits into the company culture.

Is there any open source project with a public product backlog ?

There are several good posts that pit-point some artifacts, thus you may find them useful:

Learning Scrum - The Product Backlog

EF Core in GitHub

Agile Planning and Iterations

Simple Product Backlog Example

Simple Sprint Backlog Example

Title: Scrum - real life example?

Body:
I'm starting with scrum and saw many partial examples on books and tutorials, but when try to use scrum in the real life, it's not easy to write the user stories and create the product backlog. I want to see a real project with user stories, product backlog and sprint backlogs to see if I'm doing it in the correct way.

Is there any open source project with a public product backlog ?
Is there any shared complete user stories and product backlog from a real project?


问:
What is a good design model for my new class?
I am a beginning programmer who, after trying to manage over 2000 lines of procedural php code, now has discovered the value of OOP.  I have read a few books to get me up to speed on the beginning theory, but would like some advice on practical application.

So,for example, let's say there are two types of content objects - an ad and a calendar event.  what my application does is scan different websites (a predefined list), and, when it finds an ad or an event, it extracts the data and saves it to a database. All of my objects will share a $title and $description. However, the Ad object will have a $price and the Event object will have $startDate.  Should I have two separate classes, one for each object? Should I have a 'superclass' with the $title and $description with two other Ad and Event classes with their own properties?  The latter is at least the direction I am on now.

My second question about this design is how to handle the logic that extracts the data for $title, $description, $price, and $date. For each website in my predefined list, there is a specific regex that returns the desired value for each property.  Currently, I have an extremely large switch statement in my constructor which determines what website I am own, sets the regex variables accordingly, and continues on. Not only that, but now I have to repeat the logic to determine what site I am on in the constructor of each class. This doesn't feel right. Should I create another class Algorithms and store the logic there for each site?  Should the functions of to handle that logic be in this class? or specific to the classes whos properties they set?

I want to take into account in my design two things: 1) I will add different content objects in the future that share $title and $description, but will have their own properties, so, I want to be able to easily grow these as needed. 2) I will add more websites constantly (each with their own algorithms for data extraction) so I would like to plan efficienty managing and working with these now. I thought about extending the Ad or Event class with 'websiteX' class and store its functions there. But, this didn't feel right either as now I have to manage 100s of little website specific class files.

Note, I didn't know if this was the correct site or stackoverflow was the better choice. If so, let me know and I'll post there.

答:
caveat: any design suggestions are based on what i thought you wrote, and a bag of unfounded assumptions. Code something that works, and refactor it until a 'good' model emerges - you'll end up doing that regardless of where you start, so pick something that makes sense on paper or in your mind, and start with that.

caveats aside, it sounds like you have the following classes:

Ad

Website

Event

Scanner

The Scanner scans a list of web sites, looking for ads and events. The extraction regex/logic is specific to a particular web site (thus eliminating your switch statement), but if extraction is always a regex then you can pull that from a database table to instantiate web site objects as needed (or just pull the regex from a db or in-memory table).

in other words, soft-code the web site regexes if possible, so you don't have to have a subclass for each web site

don't worry about efficiency until it works and you're happy with the underlying model, then use a profiler to see where the implementation needs to be tweaked, if at all

i suspect that a 'good' model will also naturally be efficient

good luck!


答:
We had JavaScript, then we had Flash, then we had Silverlight and then HTML5 ownd them all.

This is simply NOT true. Html5 does not own them, it introduces new markups that simplify usage of multimedia, and explores advantages of new era browsers (like using hardware acceleration while rendering html).

So what is the motivation behind TypeScript?

Motivations might be driven by reasons to use it. All features of TypeScript like : static checking, symbol-based navigation, statement completion, and code refactoring are very strong reasons to consider it.

In addition, it offers classes, modules, and interfaces to help you build robust components. These features are available at development time for high-confidence application development, but are compiled into simple JavaScript.


答:
Quick Answer: Use your approach if it makes your software work. However, look after  repeating blocks of code, because you may want to move them to common class (or business layer) later on. Thus will ensure that you are constantly refactoring and refining your code.

In this situation, i try to stick with principles of KISS and YAGNI - meaning, "Keep It Simple Stupid" and "You Ain't Gonna Need It".

KISS - would refers to keeping your code with simple constructs and easy to understand, more simpler your code, easier to maintain it is in long run. YAGNI - refers to principle in keeping your code out off over-engineering with unnecessary chunk of codes, that you think will be used in future development.

Title: What is a good design model for my new class?

Body:
I am a beginning programmer who, after trying to manage over 2000 lines of procedural php code, now has discovered the value of OOP.  I have read a few books to get me up to speed on the beginning theory, but would like some advice on practical application.

So,for example, let's say there are two types of content objects - an ad and a calendar event.  what my application does is scan different websites (a predefined list), and, when it finds an ad or an event, it extracts the data and saves it to a database. All of my objects will share a $title and $description. However, the Ad object will have a $price and the Event object will have $startDate.  Should I have two separate classes, one for each object? Should I have a 'superclass' with the $title and $description with two other Ad and Event classes with their own properties?  The latter is at least the direction I am on now.

My second question about this design is how to handle the logic that extracts the data for $title, $description, $price, and $date. For each website in my predefined list, there is a specific regex that returns the desired value for each property.  Currently, I have an extremely large switch statement in my constructor which determines what website I am own, sets the regex variables accordingly, and continues on. Not only that, but now I have to repeat the logic to determine what site I am on in the constructor of each class. This doesn't feel right. Should I create another class Algorithms and store the logic there for each site?  Should the functions of to handle that logic be in this class? or specific to the classes whos properties they set?

I want to take into account in my design two things: 1) I will add different content objects in the future that share $title and $description, but will have their own properties, so, I want to be able to easily grow these as needed. 2) I will add more websites constantly (each with their own algorithms for data extraction) so I would like to plan efficienty managing and working with these now. I thought about extending the Ad or Event class with 'websiteX' class and store its functions there. But, this didn't feel right either as now I have to manage 100s of little website specific class files.

Note, I didn't know if this was the correct site or stackoverflow was the better choice. If so, let me know and I'll post there.


答: Checkout Scrum and XP from the trenches.  It's exactly what you're asking for: stories of people who are actually using Scrum.</p>

Title: Scrum - real life example?


问:
What is the process of planning software called? Or what is the job title of someone who does software planning?
What is the process of planning software called?

For example, let's say a non-technical person comes to me with their rough initial specification. And I sit down with them over a couple weeks and help them hone, formalize and better plan the application that they want built. What is this called? Information architecture, software architecture, specification writing, software planning, requirements analysis? What is the best, most recognizable term for this?

答:
Quick Answer: It sounds to me like Business Analyst and Information Architect.

It seem that the person you have described basically helps to identify core requirements that needs to be considered in the application. - this is the a typical Business Analyst role.

However, determining how to build application on a high-level project specification is something that system architects do.


答:
I would also take your latter approach to Ads and Events, where they're both separate classes with a superclass that has title and description.  Then add additional subclasses as needed.

If I understood the rest of your post, it sounds like you have multiple regexes for each website that extract the necessary info.  In this case, as much as it might be painful, I'd create an individual class for each website that's responsible for parsing each site.  I can easily see you having to modify your regex when a site changes, or finding that a regex is inadequate and you need additional custom logic to extract the information you need.  Whenever you have to make changes to any parsing logic you'll know exactly which file to go to since it relates directly to that site.  However, I'd define an interface that these websites implement that contain common properties/methods you'll need, so that the part of the program that uses these websites can deal with a generic "Website" type to get the Ads and Events (and future objects) instead of needing to know every specific type of site in your application.

As for creating the specific type of site you need, this is where the factory pattern comes in.  Pass in a URL, get back a generic "Website" type.  Internally, your factory does the work of mapping a URL to a specific type.  It sounds like this is sort of what you're doing in your giant constructor, so I'd move that out and retool it into a factory class.

I understand it may be horrible to maintain hundreds of class files for individual sites, but if all these sites are unique I don't know what to say.  One way or another you're going to have to have unique code for each one.  Unless a bunch of ads or events all share something in common, like there's a bunch of DoubleClick ads and they all have the exact same parsing code, then you can reduce the number of classes by taking advantage of that.


答:
The process you're describing is requirements analysis:

I sit down with them over a couple weeks and help them hone, formalize
  and better plan the application that they want built

The title of the technical person doing it will likely vary depending on the organisation - but generally would fall on a Software Architect, a Systems Analyst, or a Software Developer.

Business Analysis is more over-arching, and looks more over the general business process and systems rather than specific software solutions - they'd probably pull in a more technical person to assist with that aspect.

Title: What is the process of planning software called? Or what is the job title of someone who does software planning?

Body:
What is the process of planning software called?

For example, let's say a non-technical person comes to me with their rough initial specification. And I sit down with them over a couple weeks and help them hone, formalize and better plan the application that they want built. What is this called? Information architecture, software architecture, specification writing, software planning, requirements analysis? What is the best, most recognizable term for this?


答:
It may be treated as a tool to manage javascript development rather than a total new language that compiles to JS. It do not want to be a server side development language like Dart, and not have a different syntax like CoffeeScript. It did not want to take a popular language(and it's core library) and compile it to JS like GWT or script#. TypeScript even follow same "class" syntax proposed for next version of JS.

I think most of the web development is done today uses real javascript, in the client side only. Languages or frameworks like Dart, GWT is not suitable for this. If you go for coffeescript, a new syntax comes up. And you have to understand both coffeescript and JS. While TypeScript is just adding a few extra type oriented features, melded into JS, which save developers from type-specific errors(which is a large portion of JS errors) and gives the development tools more information about developers intent.

This approach is not new. Go to the "Static Typing" section of

This article address your query- http://www.eweek.com/developer/microsoft-delivers-typescript-a-better-javascript-for-big-apps/


问:
Programmaticaly finding the Landau notation (Big O or Theta notation) of an algorithm?
I'm used to search for the Landau (Big O, Theta...) notation of my algorithms by hand to make sure they are as optimized as they can be, but when the functions are getting really big and complex, it's taking way too much time to do it by hand. it's also prone to human errors.

I spent some time on Codility (coding/algo exercises), and noticed they will give you the Landau notation for your submitted solution (both in Time and Memory usage).

I was wondering how they do that...
How would you do it?

Is there another way besides Lexical Analysis or parsing of the code?

This question concerns mainly PHP and or JavaScript, but I'm opened to any language and theory.

答:
I think that this is not possible.

If you run some tests with a fixed number of different input sizes, you can easily compute a polynomial, that will approximate the runtimes you have measured very good. So you end up with a polynomial for every possible program, which would mean P = NP (yeah! ;) ).

If you try to do it with symbolic manipulation, you end up at the halting problem. Since you can't decide wether your program will ever stop, you can't decide what runtime complexity it will have.

There may however be very special cases, where the later method is possible. But these cases maybe that small, that it's questionable if effort ever gets paid.


问:
What causes overtime and how can it be avoided?
Today, my manager told me that I must work over time to make up for a lack of planning and project management. Instead of incentivizing this unpaid mandatory overtime, my manager has made it clear I have no choice in the matter.

This isn't a single project. We currently have a dozen projects all on the go at one time, and I simply can't get them all done. Therefore, I must work overtime so we don't have to push deadlines.

Is this a sign of an ignorant or disrespectful manager, or simply an inexperienced one?

I'm in this position because of a lack of planning and project management (I think). How might I avoid this in the future? I'm no Project Manager, it isn't my strength.

What are good ways to get an employee to work overtime if you can't directly pay them? Good incentives, etc.

From what I hear, gaining your employee's respect is the single best way to get your employees to work over time, although you should never make a habit of it.

答:
My manager told me that I must work over time to make up for a lack of planning and project management. Instead of incentivizing this unpaid mandatory overtime, my manager has made it clear I have no choice in the matter.

This is a clear sign of a death march. I strongly recommend the book Death March. It will give you ideas of how to deal and cope with death marches as well as helping you decide if and when it is time to quit. Sadly, death marches are the norm in software development, and not quite the flaming emergency they are made out to be.

An article written some years ago pointed out why other industries got rid of "crunch mode" (or "death marches") - they were the worst way to get work done.

As a side question, what are good ways to get an employee to work overtime if you can't directly pay them?

Again, I refer you to the book Death March. Some organizations (notably big-4/3/2/1 accounting and consulting firms) use a "Marine Corps" mentality: "Sleep is for sissies! There will be time to sleep when we are dead!" The movie 300 has some entertaining examples of this sort of mentality. There are other methods for motivating (or trying to) workers in death marches.

If this is a one-time screw up by your mismanager, then probably the only thing to do is suck it up and get to work. If this happens all the time, then it is his/her/its incompetence at work and things need to change. A useful quote to remember comes from the movie Goldfinger:

Once is happenstance. Twice is coincidence. The third time it's enemy action.


问:
Is it possible for a good programmer to have never used version control?
I am looking for an expert programmer to help solve a difficult situation.

The interviews so far have been surprisingly disappointing. The best candidate so far is a very experienced programmer who has never used version control software.

The problem in itself might not be too serious because it is something which can be learned in a short time.

But there is a deeper aspect, which worries me:

How is it possible to actively develop software for 10-15 years without ever needing version control?

Is the fact itself of not looking for a solution to the problem of tracking changes a sign of a wrong attitude to programming?

答:
I think it depends on his attitude.  If he is a very experienced programmer, and a good programmer, I think he would be able to pick up a version control system quickly.  He may talk about it in two ways:

Good

I've never used version control, but I'm very excited to learn, and it seems like it would really help make development more efficient.  I haven't needed it as much because I've worked on projects  alone.

Bad

Version control is just a buzzword that's slowly dying in industry.  I'm above version control.


问:
Best method in PHP for the Error Handling ? Convert all PHP errors (warnings notices etc) to exceptions?
What is the best method in PHP for the Error Handling ?

is there a way in PHP to Convert all PHP errors (warnings notices etc) to exceptions ?

what the best way/practise to error handling ?

again:

if we overuse exceptions (i.e. try/catch) in many situations, i think application will be halted unnecessary.

for a simple error checking we can use return false; but it may be cluttering the coding with many if else conditions.

what do you guys suggest ?

答:
When you develop your code you should have all the error reportings in PHP enabled, including notices and warnings. Your production code should never produce a PHP Error. In some special cases you may survive with some PHP Warnings and Notices, but on your production server you should only show the Errors to the user.

Next, PHP Errors mean that you have something really messed up in your code and such things should never reach production. Any amount of decent automated tests will make sure this never happens. => Correction for clarity: "... will make sure this happens rarely."

I don't recommend you to transform PHP Errors, Warnings and Notices into Exceptions or "FALSE". Never! If they happen on your computer the application has a serious problem, so don't transform the error into something that you can catch and than forget / ignore easily.

When you have situations where your code can go wrong, use proper verification and throw exceptions. Even more, whenever possible make your own exception and throw the one most appropriate for that situation.

For example, instead of letting PHP throw an "Invalid index" when you try to read an element of an array, you may do something like:

```<code>if (!isset($superWeapons['nuclear']))
  throw new MissingSuperweaponException('We heave no nuclear weapons awailable!');
</code>```

Than, somewhere at a higher level of your application you can catch all these exceptions and show the user the nice messages you want.

Please note, that exceptions are for exceptional cases, for situations in which your application should never be. Use then only when needed.

When there is a result of an operation, a result which can be TRUE or FALSE or a value or a string, that is not an exceptional case, that is a result or a return value. For example, when you do a search for a string the result can be the index of the searched text. However, not finding the text is not an exceptional case, you should just return zero or false, not an exception.

Body:
When you develop your code you should have all the error reportings in PHP enabled, including notices and warnings. Your production code should never produce a PHP Error. In some special cases you may survive with some PHP Warnings and Notices, but on your production server you should only show the Errors to the user.

Next, PHP Errors mean that you have something really messed up in your code and such things should never reach production. Any amount of decent automated tests will make sure this never happens. => Correction for clarity: "... will make sure this happens rarely."

I don't recommend you to transform PHP Errors, Warnings and Notices into Exceptions or "FALSE". Never! If they happen on your computer the application has a serious problem, so don't transform the error into something that you can catch and than forget / ignore easily.

When you have situations where your code can go wrong, use proper verification and throw exceptions. Even more, whenever possible make your own exception and throw the one most appropriate for that situation.

For example, instead of letting PHP throw an "Invalid index" when you try to read an element of an array, you may do something like:

if (!isset($superWeapons['nuclear']))
  throw new MissingSuperweaponException('We heave no nuclear weapons awailable!');

Than, somewhere at a higher level of your application you can catch all these exceptions and show the user the nice messages you want.

Please note, that exceptions are for exceptional cases, for situations in which your application should never be. Use then only when needed.

When there is a result of an operation, a result which can be TRUE or FALSE or a value or a string, that is not an exceptional case, that is a result or a return value. For example, when you do a search for a string the result can be the index of the searched text. However, not finding the text is not an exceptional case, you should just return zero or false, not an exception.


答:
If your development and production environments are separate, you should have the display_errors ini setting set to off on production, and on (and I would set the error_reporting level to -1: all errors) on development.  It shouldn't be too difficult to write code that doesn't emit any warnings or notices through normal usage unless you're using a PEAR library, as those have a lot of legacy code that causes warnings.

As for errors and exceptions, on development you should just treat them normally so you can actually see what's wrong, and on production you can use the set_error_handler and set_exception_handler methods to catch errors and exceptions and display an error page to the user instead and write the actual error to a log file that you can check later.

Other than that, I wouldn't use any special tactics for error suppression.

Title: Best method in PHP for the Error Handling ? Convert all PHP errors (warnings notices etc) to exceptions?

Body:
What is the best method in PHP for the Error Handling ?

is there a way in PHP to Convert all PHP errors (warnings notices etc) to exceptions ?

what the best way/practise to error handling ?

again:

if we overuse exceptions (i.e. try/catch) in many situations, i think application will be halted unnecessary.

for a simple error checking we can use return false; but it may be cluttering the coding with many if else conditions.

what do you guys suggest ?


答: A programmer who has never used version control has probably never cooperated with other programmers. I would probably never consider hiring such a programmer, regardless of any other credentials.</p>

Title: Is it possible for a good programmer to have never used version control?

Body:
I am looking for an expert programmer to help solve a difficult situation.

The interviews so far have been surprisingly disappointing. The best candidate so far is a very experienced programmer who has never used version control software.

The problem in itself might not be too serious because it is something which can be learned in a short time.

But there is a deeper aspect, which worries me:

How is it possible to actively develop software for 10-15 years without ever needing version control?

Is the fact itself of not looking for a solution to the problem of tracking changes a sign of a wrong attitude to programming?


答:
There is no excuse for not using version control, even for a small project developed by single developer. Setting up local version control is beyond trivial, benefits huge. Any developer not knowing that cannot be considered good nor experienced.

As for companies perceiving version control as "novelty", which they are not willing to introduce:

SCCS was released in 1972 (40 years ago)

RCS was released in 1982 (30 years ago), and it's completely open source and free

CVS was released in 1990 (21 years ago), also completely open source and free


答: Seems like a red flag alright, but dig deeper into why he hasn't used it. I would still expect a solo developer to use version control especially in ten years but I'd be more forgiving of it than if he was working in a team and never even tried to bring in version control.</p>


答:
I worked for about 11 years in companies that didn't use source control. We managed (mostly by commenting changes and keeping code on a central server that could be recovered to any date). We never really asked whether there was a better way. That said, this was also in the days when I had the entire MSDN library in book form on my desk.

Yes, there was programming before the internet.

I struggle to see how you can spend 10+ years in the industry now without having run into source control. But, I would have some sympathy, I would believe it was possible and I wouldn't reject the candidate on that one detail alone. I would probe and find out how the candidate has managed this.

Alternatively, I might question whether my interview process was the problem. In what way was he the best candidate? Are there other modern programming techniques that he doesn't have that I'm just not asking the right questions for? If I were asking the right questions, would another candidate shine?

As a final note though, don't be afraid to reject all candidates if you have concerns. It is time consuming to start over, but it's more time-consuming to hire the wrong person.


答:
I find it incredible that a software professional has never used source control, and I'd be very nervous about hiring him.

What experience DOES he have. I would wonder what else he does not know that you have so far not found out.

What is your software development experience yourself? Are you in a position to ask him about architecture, design patterns, common software development problems, system performance questions, system security questions etc?

If he came out strong on that type of stuff, then maybe I could overlook the lack of source control knowledge.


答:
You leave a lot of information out about his experience.

Basically, I would say that it's very possible that an programmer can have 10-15 years of experience without having to know about version control. Coding for 10 years is not equal to constantly learning new programming techniques for 10 years.

I'm very young and I have seen old and "experienced" software engineers whose code I would never want to touch. That said, he might be very talented, but I would guess from the little information given that he is not.

Good luck.


问:
Servlet : Usage of Constants.java class vs context param
I'm just wondering whether to keep some of my variables in Constants class or keep it in web.xml

Say, I want to keep a variable of Facebook graph API prefix or api_key, client_id

From my understand, the difference between Constants.java and web.xml is web.xml is easier to rewrite on compile using ant.

So, you can replace your variables in web.xml according to what environment you are building you app for. (client_id varies by development environment/production environment, for example)

If I understand it right, then Facebook graph API prefix should be kept in Constants.java (because it always is "https://graph.facebook.com/") and api_key, client_id should be kept in web.xml?

What's the proper way to use them?

答:
Well it really depends on how really "constant" they are:

if they're true constants that never ever change, not when you change the deployment environment (integration, production, etc.), not when you deploy it at your client's side, than it's perfectly sensible to keep them as Java constants (final fields) in some Java class.

if they change with environment, having them as Java constants is obviously bad. Putting them in web.xml is somewhat better, but you'll still have to change something in your project to redeploy to a different environment. What I like to do in these situations is pass the values as system properties. Your app should have a generic "Config" class which is able to recuperate the value of a system property given it's name (via System.getProperty("propName")) and then configure my environment with specific values for those properties (via .bashrc, or via Web App Server start-up arguments).


问:
FP for simulation and modelling
I'm about to start a simulation/modelling project. I already know that OOP is used for this kind of projects. However, studying Haskell made me consider using the FP paradigm for modelling a system of components. Let me elaborate:

Let's say I have a component of type A, characterised by a set of data (a parameter like temperature or pressure,a PDE and some boundary conditions,etc.) and a component of type B, characterised by a different set of data(different or same parameter, different PDE and boundary conditions). Let's also assume that the functions/methods that are going to be applied on each component are the same (a Galerkin method for example). The object's mutable state would be used for non-constant parameters.

If I were to use an OOP approach, I would create two objects that would encapsulate each type's data, the methods for solving the PDE(inheritance would be used here for code reuse) and the solution to the PDE.

On the other hand, if I were to use an FP approach, each component would be broken down to data parts and the functions that would act upon the data in order to get the solution for the PDE. Non-constant parameters would be passed as functions of something else (time for example) or expressed by some kind of mutability(emulation of mutability,etc.) This approach seems simpler to me assuming that linear operations on data would be trivial.

To conclude, would implementing the FP approach be actually simpler and easier to manage (add a different type of component or new method to solve the pde) compared to the OOP one?

I come from a C++/Fortran background, plus I'm not a professional programmer, so correct me on anything that I've got wrong.

答:
IMHO for almost every task of reasonable complexity the question "is an FP style or OOP style the better choice" cannot be answered objectively. Typically, in such a situation the question is not "either FP or OOP", but how to combine the best parts of both paradigms for solving your problem.

The problem you have scetched above seems to be a very mathematical one, and I make a wild guess that you will need some matrix operations. OOP is very good for modeling abstract data types, and matrix calculus can be easily implemented as "matrix objects" with operations on matrices. Implementing this in a manner where all matrix operations are part of a matrix class helps you to keep things together which belong together, so maintaining a good overall structure.

On the other hand, PDEs are equations on functions, and the solution may be function again. So using a functional approach for that type of "components" may seem natural here. Those functions may have matrix parameters, showing one example of how to combine OOP and FP. Another example would be a matrix class implementation, which uses functional tools to map a certain operation to every element of your matrix. So here, too, it is not "OOP versus FP" but "OOP combined with FP" which brings you the best results.

Title: FP for simulation and modelling


答:
Let me give you some perspective from doing software development in DOS and Windows for over 20 years.

Version control software in the Windows/PC world was often unreliable in the early-mid 90's. Visual Sourcesafe (VSS) was about the best Windows based one around but it could be quirky and many programmers hated it. Some teams simply wouldn't entertain their use after dealing with this situation.

Most other VCS options at the time weren't Windows based and, therefore, were rarely used in Windows development teams. Some of these were expensive solutions and open source solutions weren't as accepted as readily as they are today.

In many cases, during the late 90's, early 00's, if a Windows team didn't use VSS, they didn't use anything for source control aside from in-house conventions. A number of them still don't use a VCS in spite of the sophistication of Team Foundation Server (TFS) and great free options like git and SVN.

It's possible that someone who worked for years in a small Windows development team for years to have not used a VCS. I've interviewed at and even done contract work at some places that didn't use them or that were very haphazard about their use.

So, I don't think your candidate's lack of experience in this area is a definite 'no' but you probably want to delve more into their previous work situation to find out why this is missing from their experience. You'll also want to explore their attitude toward version control. Do they think it's a good idea but they weren't allowed to pursue it at their previous position or do they think it's a waste of time?


答:
I wouldn't be religious about lack of version control experience. It's only a tool. In the end, you can pick up the basics of svn or git in a day or two. The rest you'll pick up with time. And I can't believe that any half-decent candidate wouldn't be able to fit in if he was to work in an environment that uses source control.

Using source control is more of a habit than a skill. Someone who has never used it may exaggerate the effort required and underestimate the benefits gained. After all, he did fine until now. Only after he actually uses source control, he'll grow to appreciate it.

The question you should ask is, how did he manage in the absence of source control? This could tell you something about him and how he manages his work.


答:
How is it possible to actively develop software for 10-15 years without ever needing version control?

If he is coming from old school teams where small projects are managed by a single person, it is very possible. He may have 10 years of experience in the same technology set without learning and improving himself.

Is the fact itself of not looking for a solution to the problem of tracking changes a sign of a wrong attitude to programming?

If your candidate has been in a team development (at least 4 or more programmers) environment then it is a trivial question. However, there might be a work division between programmers, worked on modules solely assigned to them, which may reduce the need to source control the code.

However, not being heard about source control in internet era is really surprising situation. Thus, i would look at his willingness to learn new things (concerning your development environment) and how open is he to a dynamic work environment.


答:
Short Answer: If you use PHP 5, you can handle error with exceptions:

http://fr2.php.net/manual/en/class.exception.php

This way is cleaner than manual set exception message, because you have access to a try catch system and you can isolate exception handling


问:
Is time tracking required for web based/service industries?
I work in the web development industry and we implement a time tracking system to log our time (Project/time/comment). In the beginning of a project, we create a contract, and decide upon a price based on our hourly rate x estimated hours.

We log out times to see if we go "over budget". Is time tracking in this industry the norm? Is it required? What are the pros and cons?

答:
Time tracking is a wonderful tool for:

making your estimates more accurate

managing the size of your team

justifying invoices when a client takes issue with what they are being billed

providing more data for performance bonuses (temporal efficiency is important, but only if it comes with quality)

finding the drag in your workflow so that you can become more efficient over time

choosing the types of work at which you can be more cost-effective/efficient than your competition

scheduling projects more effectively

The problem is that when done wrong (which is easier than doing it right) time tracking itself can be the drag on your workflow.  I have a colleague who, in a very unscientific study of me sharing an office with him for two days during which I was curious enough to time him, spent 15% of his time documenting how he spends the other 85%!

To my mind (though I admit I'm a better technician than business strategist) that is way too much overhead for time tracking.  In a small company, doing it this badly is, in my opinion, worse than not doing it at all.


答:
Can't you have version control without version control software? Ask how they managed their code. Maybe there was a home-grown system already in place.

Wanting to do things manually, reinventing the wheel and being resistent to change are nothing new to programming. Are you going to drool over a candidate that uses Visual Source Safe and "only" VSS?

When trying to find talent, you have to be able to tell the difference between: can't, haven't and won't.


答:
I have worked at locations where the process of getting software approved was 12 to 18 months. If it wasn't already on the list of approved software there was no way to get it on the machines. CD/DVD drives were locked down, and the machines were not connected to the internet.

The first place I ran into source control the solution was to have a developer write their own, by the time it was ready for testing the multi-year project was winding down. They gambled that writing it from scratch was faster than the approval process.

The 2nd place that I ran into this problem did use source control for the first few months, but then the customer wanted all development done on their internal network. They again locked down everything, so it was back to lots of zipped folders.

I know developers that have only worked in these conditions. They want to use these tools, they would love to use these tools, but they are not allowed to use these tools.

Investigate why they have not used them. Not understanding the procedures because of zero experience, is far different than rejecting the tools.


答:
Is it possible for a good programmer to have never used version control?

Yes. Many small companies with self taught programmers don't use it.

How is it possible to actively develop software for 10-15 years without ever needing version control?

I have personally introduced version control to 2 small companies, have upgraded 1 medium company from something god awful to SVN (best option at the time) and worked in another small company that had only some VC, wrote their own VC solution for some code and had lots of code just not in any VC.

Is the fact itself of not looking for a solution to the problem of tracking changes a sign of a wrong attitude to programming?

Well it's not an instant fail, but I would certainly be asking lot's of follow-up questions. Things like:

Have you ever tried any VC software? What? What did you think of it?
Is there any reason you wouldn't use it? What have you used before to
manage code? Have you worked with anyone before on the same code
base, and what methods did you use to avoid clashes?


问:
Licensing code under GPL: are revisions prior to adding GPL license still GPLed?
Suppose I have an already existing codebase which does not have any license headers in any of the source files, nor does it have COPYING file.

So when I add all the neccessary GPL "cruft" to, say, revision 1000, will all previous revisions be GPLed as well or do I need to rewrite my repository history to include GPL license from the revision 0?

答:
No - the GPL license controls how the code is to be distributed, it isn't an intrinisic property of the code. Code doesn't become GPL - it is distributed under the GPL

If you aren't distributing the earlier versions of the code then the license has nothing to do with it.


答:
I'd like to agree with Explosion Pills (but my rep's too low, atm...)... attitude is far more important.

There are a few things to look for, that I believe make for programming excellence:

Communication

Creativity

Compassion (say what?)

And, often times, more than a little OCD.

You know the type... the ones who sit there hammering on a problem, completely losing themselves in their code as they explore options. These are the ones who take notes as they go along, leave comments in their code to make sure that they understand their own logical paths (and to light the way for themselves or other programmers who might have to deal with the code in the future ... thus, "compassion" in my list above!), and quickly and clearly convey complex ideas to decision makers up the chain so that problems can be addressed efficiently.

An excellent programmer may have been stuck for years in an environment that either didn't buy into the idea of VCS, had bad experiences with VCS (a la VSS) which made them gun-shy to try new systems, but I would guarantee that an excellent programmer in that situation would still have set up some sort of routine to protect themselves from losing all their work to a couple bad design iterations.

The kind of programmer to beware of, therefore, is the one who claims to have never needed VCS, nor any measure of protection from inevitable screw-ups. Their attitude is one of "well, I built it, therefore it can't be wrong." Those are the ones I fear more than any novitiate straight out of college, because a novice can learn to appreciate the strengths of VCS because they realize how little they actually know.


答:
Personally, the most alarming thing to me is that the candidate has either never encountered version control systems as a concept, or has decided that it is not worth using. I find the first scenario highly unlikely, but if that is the case, then it leads me to assume the candidate has been significantly isolated for the duration of their career, which would cast serious doubt on their value as a part of a team. Specifically, they may very bizarre concepts about how to do certain things and not know any of the "right" way to do things.

If it's the second case, where they have actively decided against version control, then it makes me assume that they either never worked on anything of significance, or are extremely arrogant. Or, at best, they have really terrible ways of maintaining code like commenting out blocks, and attributing every line of code to an author, date, and bug number.


答: I am developing for last 15 years. Used the version control only few times. I am still using my own scheduled scripts and programs to backup all development folders incrementally. I don't know what to say If somebody asks me If I use Version Control. I have never been in need of version control system, I always worked on tiny projects. I mean I am not the best programmer out there but I am sure I am not the worst. Most of the time I am embarrassed to tell people that I don't regularly use version control system, but that is how it is for me.</p>


问:
How is technical debt best measured? What metric(s) are most useful?

Possible Duplicate:

  How can I quantify the amount of technical debt that exists in a project?

If I wanted to help a customer understand the degree of technical debt in his application, what would be the best metric to use? I've stumbled across Erik Doernenburg's code toxicity, and also Sonar's technical debt plugin, but was wondering what others exist.

Ideally, I'd like to say "system A has a score of 100 whereas system B has a score of 50, so system A will most likely be more difficult to maintain than system B".

Obviously, I understand that boiling down a complex concepts like "technical debt" or "maintainability" into a single number might be misleading or inaccurate (in some cases), however I need a simple way to convey the to a customer (who is not hands-on in the code) roughly how much technical debt is built into their system (relative to other systems), for the goal of building a case for refactoring/unit tests/etc.

Again, I'm looking for one single number/graph/visualization, and not a comprehensive list of violations (e.g. CheckStyle, PMD, etc.).

答:
You don't mention what environment/language you want to provide metrics for. If you're using Visual Studio Ultimate, the code analysis tools provides a maintainability index as a score from 0-100 at the solution, project, class, and even method level.

Aside from that, a good indicator of maintainability is cyclomatic complexity. There are a number of tools that will calculate it for you automatically across multiple languages and environments. This question provides a list of them.


答:
Instead of books, you can also try some project management software, which follows scrum methods. Some applications also analyze, if you are doing it the right way by some rules. There should be a few applications on the internet, either as a desktop application or as a webservice.

Personally I wouldnt do it exactly by the book, but rather apply it to your workflows iteratively and improve your current project management processes by scrum and other agile methods. There are a few, which are very similiar to scrum. So in the end you could have some variation, which is easier to adopt for you and your team and still as effective as the original.

Title: Scrum - real life example?


答:
The default status for copyright in most countries is "all rights reserved". So, any previous distribution of the code by yourself did not grant the receipients the right to modify or distribute the code.

Adding cruft to each source file isn't necessary; it's just common practice.

Title: Licensing code under GPL: are revisions prior to adding GPL license still GPLed?

Body:
Suppose I have an already existing codebase which does not have any license headers in any of the source files, nor does it have COPYING file.

So when I add all the neccessary GPL "cruft" to, say, revision 1000, will all previous revisions be GPLed as well or do I need to rewrite my repository history to include GPL license from the revision 0?


问:
Differences between TypeScript and Dart
Microsoft recently unveiled Typescript, a new JavaScript-like programming language.
Some time ago, I heard about Dart, a new programming language created by Google to solve problems related to Javascript like performance, scalability, etc..

The purpose of both new languages seem the same to me.. What do you think?

Are the purposes of the languages the same?

What are the real differences about them?

答:
Quoting Scott Hanselman:

People have compared TypeScript to Dart. That's comparing apples to
  carburetors. TypeScript builds on JavaScript so there's no JS interop
  issues. Dart is a native virtual machine written from scratch. Dart
  interops with JavaScript...but it's not JS. It doesn't even use the
  JavaScript number type for example.

From Why does TypeScript have be the answer to anything?

Title: Differences between TypeScript and Dart


问:
Is it okay for programmers to be given the task of outlining database requirements?
In my current job, dba's and programmers are divided in tasks. Any code that needs to be written in procedures dba's write, and programmers do only application code.

The strange thing is that whenever a task needs to be defined/specced, programmers get the task, and we have to define all the procedures needed and what they should return.

Is this a common practice in software development? Are programmers generally the ones tasked with building requirements for the database side?

答:
Who else would you suggest should do it?

Think of it this way: Team A and team B work for the same company. If team A is required to provide an API for team B, who defines the requirements? Surely not Team A, without any knowledge of the application to be built on top of it. It must be team B.

Team A decides how to implement the API and they may insist on limitations for team B, but they cannot define what is required.

Does this change if the two teams are writing in different languages? No. So why should it change if team A is a DBA team?


答:
Yes, it's very common practice when operating a business or company that sells "Professional Services" or "Coders for Hire on a per-Project Basis."

It is less common for other types of business model, such as retail software development.  In these spaces, if you are doing time tracking, it is usually for internal auditing of planning accuracy, estimation accuracy, and employee performance.  Not for billing.

Title: Is time tracking required for web based/service industries?

Body:
I work in the web development industry and we implement a time tracking system to log our time (Project/time/comment). In the beginning of a project, we create a contract, and decide upon a price based on our hourly rate x estimated hours.

We log out times to see if we go "over budget". Is time tracking in this industry the norm? Is it required? What are the pros and cons?


问:
Project Management Software / 1 maybe 2 developers
I am looking for software that I can use to "manage" multiple projects (5 - 10). Here are the features I would like but any recommendation is welcome.

Bug/Feature tracking on a per project basis.

Some way to keep all documents, diagrams, specs, requirements, in one place with the project. Better yet a tool where all these things or most of them could be authored.

Task management during the development phase with milestones and estimates/actuals.

Git integration

I have been doing contract work and i have been doing really well for myself as far as getting projects but its becoming VERY hard to manage everything in an efficient manner. I am trying to learn about best practices when it comes to software programming methodologies and the more I read the more i realize that I am just managing these projects poorly. I am getting things done but the more I take on the less "solid" everything is. I am afraid if I don't get some good solid tools/practices in place I am going to do my customers and myself a disservice. The problem is that there are SO many options that its hard to weed through them all. I was at a point today where I had decided that I would just code my own (there is some irony here)!

Obviously everyone has their likes dislikes I would love to hear from some of you lone programmers and how you manage everything since our needs aren't exactly the same thing that a large team might need. I also want a solution that can scale to 2 maybe 3 developers if I end up hiring some people to help with my work load.

Thanks again for your usual insights!

答:
Having everything in one tool seems a bit tricky.

Why not use Jira to track bugs and a dedicated tool for managing and scheduling activities?
You can take a look at http://www.onepmo.com that comes with a scheduling engine; it means that it automatically solves resource conflicts and calculates everything for you.


答:
I don't think it is common practice for DBA's to write stored procedures during the development of a program. Personnaly, I always had to write my own stored procedures, or sql code.

I think that since they know their database product much more than programmers (in theory, and at least it's true for me), they are best used whenever something that needs more analysis needs to be done on the database:

defining and optimizing table, tablespaces, indexes, etc.

optimizing stored procedures

database migration plan

etc. (DBA's, feel free to complete this list)

"Optimization" is the key I think.

A few years ago, I remember I asked my Oracle DBA about optimizing a procedure that was performing very poorly (like more than 10 seconds for only a few results). He came back to me with a request I did not understand at all containing keywords I've never seen before at that moment in time (INTERVAL and how to use partitioning are extremely powerful when put at good use) and that was giving the same good results in less than 25ms...

As for programmers, they have to conceptualize the database, provide the scripts and work together with the DBA so that the resulting database schema is most efficient for the required tasks. Programmers and DBA's should work together to identify/resolve bottlenecks occurring between the application and database servers.

Title: Is it okay for programmers to be given the task of outlining database requirements?

Body:
In my current job, dba's and programmers are divided in tasks. Any code that needs to be written in procedures dba's write, and programmers do only application code.

The strange thing is that whenever a task needs to be defined/specced, programmers get the task, and we have to define all the procedures needed and what they should return.

Is this a common practice in software development? Are programmers generally the ones tasked with building requirements for the database side?


答:
Measure technical debt in terms of the amount of work required to eliminate the debt: if it'll take you and your team 3 months to get your code to the shape you'd like it to be in, you've got 3 team-months of debt. The cost of carrying the debt, like interest on a loan, is the amount of extra work that you incur due to the debt: if 50% of the work your team does in a month would be eliminated if your code were in ideal shape, that 50% is the "interest" that you pay on the debt.

Of course, it's impossible to know exactly how long fixing your debt will take until you do it, so it's only possible to measure these things precisely after the fact. And at any rate, the value in the idea of technical debt is simply to express the degree to which compromises and delayed work have or will become a problem for your project. A good accounting of the work required to reduce your debt will help in project planning, but other than that it may be more useful to express the debt in t-shirt sizes: small, medium, large, extra-large.

Title: How is technical debt best measured? What metric(s) are most useful?

Body:
Possible Duplicate:

  How can I quantify the amount of technical debt that exists in a project?

If I wanted to help a customer understand the degree of technical debt in his application, what would be the best metric to use? I've stumbled across Erik Doernenburg's code toxicity, and also Sonar's technical debt plugin, but was wondering what others exist.

Ideally, I'd like to say "system A has a score of 100 whereas system B has a score of 50, so system A will most likely be more difficult to maintain than system B".

Obviously, I understand that boiling down a complex concepts like "technical debt" or "maintainability" into a single number might be misleading or inaccurate (in some cases), however I need a simple way to convey the to a customer (who is not hands-on in the code) roughly how much technical debt is built into their system (relative to other systems), for the goal of building a case for refactoring/unit tests/etc.

Again, I'm looking for one single number/graph/visualization, and not a comprehensive list of violations (e.g. CheckStyle, PMD, etc.).


问:
What is the best way to go about testing that we handle failures appropriately?
we're working on error handling in an application. We try to have fairly good automated test coverage. One big problem though is that we don't really know of a way to test some of our error handling.

For instance, we need to test that whenever there is an uncaught exception, a message is sent to our server with exception information. The big problem with this is that we strive to never have an uncaught exception(and instead have descriptive error messages).

So, how do we test something what we never want to actually happen?

答:
Simulate the failure / exceptional situation.

Your mock objects are crash test dummies and you already know what can possibly go wrong, it shouldn't be hard to emulate it (you know because you've already prepared for it, if you don't, well, you'll soon find out ;). And... it's always amazingly fun to physically unplug your database server while your processes are running. Doesn't really scale as a testing method, but it's awesome even if you do it just once.

Consider this trivial / overly simplistic example:

Class A does something, and throws an OMGSomethingBroke exception if something goes awry.

Class B calls Class A, and in case something breaks, catches the exception and logs it (or whatever).

What you need to do is create a mock of Class A, let's call it Mock A that does nothing more than throw the OMGSomethingBroke exception. Mock A and Class A should implement the same interface, and that's about it. You've emulated the failure, and you can now move on to testing Class B. Have it call Mock A instead of Class A, and test if it handles the failure gracefully.

Testing can be exceptionally simple if your design is solid (yes, both puns intended).

Just found a very interesting Udacity course, Software Testing (CS258) - How to Make Software Fail:

When writing software, destruction can be just as valuable as creation. Learn how to catch bugs and break software as you discover different testing methods that will help you build better software.

The course has a wider scope than your question, obviously, but the core message in its summary applies: Breaking stuff is fun! (Well, and a good way to test software).


答:
Is it okay for programmers to be given the task of outlining database requirements?

If the programmers are the ones who need a certain procedure, table, trigger, or whatever in the database, then it makes sense for them to give requirements to the DBAs and have them actually do the work, especially if the programmers are not very proficient in whatever stored procedure language is being used.

In my experience, many programmers also write stored procedures because this particular system runs mostly within the database and there simply aren't enough DBAs to go around. On the other hand, having the DBAs do the programming (or consult if they are too busy) can be a good thing as they may have insights on better ways to write performance-critical procedure code.


答:
This is one of the many reasons why modularization is a good idea.

Your test is supposed to test the behaviour of one bit of code, and one only. In this case, it's the code that sends email when a different bit of code generates an error. So what you do is hook up a mock version of the other bit of code that does create an error, to your actual, production-grade error handler, and then verify that it does send email. (You can also replace the email sending code with a mock version, too, so it doesn't actually send the mail but just reports that it would have done so - makes the test much easier and faster.)

That way, everyone is happy: Your error handler is tested, your production code never causes errors (that you know of), and you still know hat would happen if it did. If your code base doesn't support such flexible hook-ups, well this is one major reason why it should.

Title: What is the best way to go about testing that we handle failures appropriately?

Body:
we're working on error handling in an application. We try to have fairly good automated test coverage. One big problem though is that we don't really know of a way to test some of our error handling.

For instance, we need to test that whenever there is an uncaught exception, a message is sent to our server with exception information. The big problem with this is that we strive to never have an uncaught exception(and instead have descriptive error messages).

So, how do we test something what we never want to actually happen?


答:
I am seeing some rather judgmental answers here that don't actually take into account the person being judged.

I personally find version control software to be an invaluable tool.  But, we don't all have choice and control about the tools and processes that are used in our work environments.  I have worked in Windows development since 1990.  As posted by others, at that time there wasn't much available for VCS in Windows.  We were not going to bring in UNIX servers just to get a VCS.  Did that make me a bad programmer?  Later in my career, I worked for a company with a vertical market commercial product where version control was a process not a tool.  Did that make me a bad programmer?  My last three jobs have all relied heavily on VCS tools.  Does that make me a good programmer?

It would be great if we all got to use only the latest and greatest tools, languages and technologies.  But the profession of software development doesn't always work that way.  It is a little idealistic to say "I would leave the job immediately, if they didn't..." or "I would never take a job that didn't use..." or "I would force them to use...". We aren't all surrounded by an infinite supply of job opportunities where everything works exactly as we want.  We have bills to pay and need a job, so we deal with what is around us.

In the end, the answer to your question is this: Judge this programmer by his skills, his philosophies and his decisions,  not the (possibly misguided) decisions made by the people in charge at his prior jobs.


问:
"Do you have any questions for us?" In an interview
You know the prospective company fairly well but are asked "Do you have any questions for us?".  To show interest, what are some of your favorite questions to reply?</p>

答:
Is this a new position, or are you filling a pre-existing one?

If the position is pre-existing then you can ask (but don't expect an answer most of the time):

Why did the last employee leave?