问:
Is return-type-(only)-polymorphism in Haskell a good thing?
One thing that I've never quite come to terms with in Haskell is how you can have polymorphic constants and functions whose return type cannot be determined by their input type, like

```<code>class Foo a where
    foo::Int -> a
</code>```

Some of the reasons that I do not like this:

Referential transparency:

"In Haskell, given the same input, a function will always return the same output", but is that really true? read "3" return 3 when used in an Int context, but throws an error when used in a, say, (Int,Int) context. Yes, you can argue that read is also taking a type parameter, but the implicitness of the type parameter makes it lose some of its beauty in my opinion.

Monomorphism restriction:

One of the most annoying things about Haskell. Correct me if I'm wrong, but the whole reason for the MR is that computation that looks shared might not be because the type parameter is implicit.

Type defaulting:

Again one of the most annoying things about Haskell. Happens e.g. if you pass the result of functions polymorphic in their output to functions polymorphic in their input. Again, correct me if I'm wrong, but this would not be necessary without functions whose return type cannot be determined by their input type (and polymorphic constants).

So my question is (running the risk of being stamped as a "discussion quesion"): Would it be possible to create a Haskell-like language where the type checker disallows these kinds of definitions? If so, what would be the benefits/disadvantages of that restriction?

I can see some immediate problems:

If, say, 2 only had the type Integer, 2/3 wouldn't type check anymore with the current definition of /. But in this case, I think type classes with functional dependencies could come to the rescue (yes, I know that this is an extension). Furthermore, I think it is a lot more intuitive to have functions that can take different input types, than to have functions that are restricted in their input types, but we just pass polymorphic values to them.

The typing of values like [] and Nothing seems to me like a tougher nut to crack. I haven't thought of a good way to handle them.

答:
Concerning your question about referential transparency on polymorphic values, here's something that may help.

Consider the name 1. It often denotes different (but fixed) objects:

1 as in an Integer

1 as in a Real

1 as in a square identity matrix

1 as in an identity function

Here it is important to note that under each context, 1 is a fixed value. In other words, each name-context pair denotes a unique object. Without the context, we cannot know which object we are denoting. Thus the context has to be inferred (if possible) or explicitly provided. A nice benefit (aside from convenient notation) is the ability to express code in generic contexts.

But since this is just notation, we could have used the following notation instead:

integer1 as in an Integer

real1 as in a Real

matrixIdentity1 as in a square identity matrix

functionIdentity1 as in an identity function

Here, we gain names that are explicit. This allows us to derive the context just from the name. Thus only the name of the object is needed to fully denote an object.

Haskell type classes elected the former notation scheme. Now here's the light at the end of the tunnel:

read is a name, not a value (it has no context), but read :: String -> a is a value (it has both a name and a context). Thus the functions read :: String -> Int and read :: String -> (Int, Int) are literally different functions. Thus if they disagree on their inputs, referential transparency is not broken.

OwnerDisplayName: dainichi


问:
Should programmers itemize testing for projects?
I recently hired a programming team to do a port of my iPad app to the iPhone and Android platforms.

Now, in a separate contract, I am asking them to implement a bunch of tips on how to play the app, similar like you would find in Candy Crush or Cut the Rope.  They want to charge 12 hours @ $35/hr for the "Testing all of the Tips", telling me that normally it would take them more than 25 hours but that they will 'bear the difference'.

I am not familiar with this level of itemization, but maybe it's a new practice?  I am used to devs doing their own quality control, and then having a testing/acceptance period.

They are using Cocos 2D-X, and they say that the tips going to multiple platforms makes all of the hours jack up.  I feel like they might be overcharging, and it's difficult for me to know because it's kind of like with a mechanic.  "It took us 5 hours to replace the radiator".  How can you dispute that?

It seems to me that most of you would charge for the work but NOT for hours that you are 'testing'. Am I missing something?

Thanks for any help and advice you can give!

答:
To determine whether or not the software "works" you and the software developers evaluate the software against the software requirements that you provided to them, and determine whether or not the software they provide to you actually meets those requirements.  The way you direct this process is by providing testing requirements within the requirements themselves.

Software requirements should be specific, measurable, attainable, relevant, and time-bound.  Every requirement must also be accompanied by clear, specific and unambiguous criteria that demonstrates that the requirement has been met.  Generally speaking, that means you're defining a test as part of the requirement; if it passes the test, you declare success.  If you have requirements like that, then you already have a built-in mechanism for insuring that your software developers deliver the product that they promised, because they have to demonstrate to you that the software meets each of the requirements, in the manner stated in the requirement.

Tips for writing testable requirements include:

Use short, direct, complete sentences

Make requirements internally & externally consistent

Remove ambiguity

Make requirements measurable

Make requirements finite

Include testers in the requirements peer reviews

Define a testing strategy for each requirements as  soon as it is specified

Trace requirements to test cases

If the tips were part of the original requirements/specifications that you provided to them, and they bid the job on a fixed-cost basis based on those requirements, then they are obligated to deliver to you an app that works.  If they need to test it to make sure that it works when they deliver it, then that's what they need to do.  Otherwise, they will be fixing problems that you find later, for free.

Further Reading

Writing Testable Requirements

ContentLicense: CC BY-SA 3.0


问:
How do you cope with ugly code that you wrote?
So your client asks you to write some code, so you do. He then changes the specs on you, as expected, and you diligently implement his new features like a good little lad. Except... the new features kind of conflict with the old features, so now your code is a mess. You really want to go back and fix it, but he keeps requesting new things and every time you finish cleaning something, it winds up a mess again.

What do you do? Stop being an OCD maniac and just accept that your code is going to wind up a mess no matter what you do, and just keep tacking on features to this monstrosity? Save the cleaning for version 2?

答:
My preference is to avoid this situation in the first place.

It all depends on HOW you read the spec.  Its easy to think of them as stone tablets, but in reality most specs change. When you design your code, take a view on how likely that each part of the spec is going to change.  Over time, you will get quite good at predicting this.

Having got into the mess, experience and judgement is very important. Are you writing new bugs because of this spaghetti code? is it taking longer to implement? these would point to doing a tactical refactor.

for the future, it sounds like you need to work in partnership with your customer.  Saying to them, "look this product is expanding significantly beyond the original spec.  Whilst the original design was good for that level, expanding it in direction X and directions Y need some restructuring in the design" handled well, and you will even get your customer to pay for it.

ContentLicense: CC BY-SA 2.5


问:
Should I teach my students alloca?
How widely used is alloca in the real world? Should I teach my students to use alloca when it makes sense? Or should I teach them never to use it? Coming from a C++ RAII background, the idea of not having to call free manually sounds promising, especially in functions with multiple exit points.

答:
The GCC documentation has a couple practical pros and cons on alloca().  From a practical perspective, a decent amount of free software uses it, so it's good to be understand how it works and where it's used in existing code.

Passing -Wl,-stack=new-stack-size to gcc increases the maximum stack size; you'll need to do this if your project uses alloca(), or allocates large temporary arrays or uses recursion past a certain context-dependent depth.

OwnerDisplayName: FredOverflow

Title: Should I teach my students alloca?


答: Charge by the hour and if he wants changes say that is fine but incorporate the time required to write good code into the equation. Also remember writing neater code pays off long term when you have to maintain it. Saving time now could cost you later.</p>

Title: How do you cope with ugly code that you wrote?

Body:
So your client asks you to write some code, so you do. He then changes the specs on you, as expected, and you diligently implement his new features like a good little lad. Except... the new features kind of conflict with the old features, so now your code is a mess. You really want to go back and fix it, but he keeps requesting new things and every time you finish cleaning something, it winds up a mess again.

What do you do? Stop being an OCD maniac and just accept that your code is going to wind up a mess no matter what you do, and just keep tacking on features to this monstrosity? Save the cleaning for version 2?


问:
How to sell Agile development to (waterfall) clients
Our development shop would really like to do more agile projects but we have a problem getting clients on board. Many clients want a budget and a deadline. It's hard to sell a client on an agile project when our competitors do come up with waterfall-based fixed deadlines and fixed prices. We know their fixed numbers are bad, but the client doesn't know that. So, we end up looking bad to the client because we can't fix the price or a deadline but our competitors can.

So, how can you get your sales force to successfully sell a project that uses agile development methods, or a product that is developed using such methods? All the information I found seems to focus on project management and developers.

答:
The main hurdle in achieving the benefits of Agile-Scrum outside software development is integrating it with existing control mechanisms. These control mechanisms are stipulated due to various organizational prerequisites and are normally actualized by using the Linear Waterfall approach and methodology.

Four of these typical organizational prerequisites are depicted below:

Big global corporates – in these hierarchical matrix organizations, top down portfolio control is the rule of the day. The free spirited agile approach has a tough time adjusting to the rigorous controls. Specifically the inherent Agile plan-free concepts, make Agile-Scrum difficult for the organization to swallow.

Highly regulated industries – some industries are required by compliance and governance bodies to have a strict binding control mechanism. These can be for example medical equipment, aircraft, and pharmaceuticals research and product development business units. While individual teams might operate Agile-Scrum, the development process must follow a rigid Linear Waterfall approach method for traceability and governance.

Complex predefined products – some integrated products which include both hardware, software, imbedded and more are developed as a contract with an end customer under a predefined set of requirements. In these cases the degree of requirement flexibility is small, though larger than what is anticipated initially. The concept of a fully flexible backlog of Agile-Scrum suffers considerably in these cases.

Generic IT departments – much of the daily and weekly activities in maintenance driven IT departments is ad hoc. Changes to the daily schedules are numerous and immediate. Constant interferences in the teams work are the norm. The concept of time boxing and no interference is difficult to maintain in these situations.

Naturally – many times the four discrete categories detailed above, actually mix; so it is common to find a complex product in a global big corporate which is required to comply with firm regulation.

Based on practical experience, the recommended method to tackle these scenarios and others is by empowering the Agile PMO to act as an enabler, driver and translator between the emerging Agile-Scrum teams and the Linear Waterfall elements.

Refer to the table below for specific guidelines

Source - Interfacing between Linear Waterfall and Agile Approaches by Michael Nir


问:
Why is Internet Explorer the only browser to be referred to by version when talking about compatibility?
Whenever I read something or hear someone talking about HTML5, CSS and JavaScript support, they always refer to Internet Explorer with the version number such as Internet Explorer 6, and Internet Explorer 9. But they only refer to Google Chrome, Firefox, Safari and others without version numbers.

Shouldn't they also specify the version number in which certain web technologies are incompatible for other browsers instead of just Internet Explorer?

答:
Well, that mainly has two reasons:

1. IE versions have major differences

While other browsers may have no (obvious) difference between versions, Internet Explorer, being the only browser pre-installed (and basically hard-coded) in Windows, has huge differences from version 6 to version 10. Version 10 is almost as good a browser as Chrome or Firefox, while version 6 is an unreliable, slow, good-for-nothing, over-customized browser still used by some non tech-savvy, and it is incompatible with thousands of features introduced after it was created (that was over a decade ago).

You can see some compatibility examples here.

2. Being pre-installed has an impact on the market

Since IE comes with Windows, and while other OS are gaining up publicity, Windows has been the default for thousands (if not millions) of people, for a long time. Since these people hire programmers to do stuff, like make their websites, programmers are forced to make it look good on the client's screen, even if that doesn't always target the largest audience.

Of course, most of us are trying to have a good result on both the client's screen and their clients' screens, but that isn't always easy, if our client has IE 6. (And believe me: some of them will think that you are not a good developer if you ask them to change their browser)

So, in conclusion, we tend to always refer to IE with its version, because it does mean something different for development.

P.S.: Here is a great blog article about the history of IE and why geeks hate it which does a great presentation on a once good browser.


问:
Optimising news fetching
I have a web scraper for scraping news from different sources in wp7. My current appraoch for doing this is:

load newspapers information from xml file.

go to the specified sections and fetch the urls of the news items.

go to each url and fetch headline, image, publisher.

display using a MVVM architecture of windows phone.

The whole thing takes place asynchronously...meaning as soon as url from a section of a newspaper is fetched it is added to the queue, and the second stage consisting of fetching headline, image etc starts... and as soon this is fetched even for one article, it is displayed. Later on as more articles are fetched, they are added on to the list.

For the fetching purpose I am using a SmartThreadPool(http://www.codeproject.com/Articles/7933/Smart-Thread-Pool) for windows phone.

My problem is that...even for fetching around 80 items (in total) from 9 publications, it is taking more than a minute. How can i speed up the procedure?

Note: I have a two stage approach because many times the images are not available with headlines, and are only found in the article.

答:
There is one foolproof technique for optimizing your code: measure.
Without knowing where the bottleneck is, any advice you get will have a good chance of being useless. Measure. Time your code. Make sure you know exactly what is taking so long.

Your code is broken down into segments, right? Measure them separately, then measure as a whole. Make sure you know how long it takes to load the XML data, how long it takes to fetch the list of articles from a source, how much time to fetch an item's content, how much time it takes to load its images.

Unless you measure, your optimizations will be premature. It's entirely possible you'll spend a week optimizing your network fetching code, only to discover your problem was in your View Models which accidently fetched data multiple times.

Measure.

Title: Optimising news fetching


问:
Is it possible to create a single tokenizer to parse this?
This extends off this other Q&A thread, but is going into details that are out of scope from the original question.

I am generating a parser that is to parse a context-sensitive grammar which can take in the following subset of symbols:
,, [, ], {, }, m/[a-zA-Z_][a-zA-Z_0-9]*/, m/[0-9]+/

The grammar can take in the following string { abc[1] }, } and parse it as ({, abc[1], }, }).
Another example would be to take: { abc[1] [, } and parse it as ({, abc[1], [,, }).

This is similar to the grammar used in Perl for the qw() syntax.  The braces indicate that the contents are to be whitespace tokenized.  A closing brace must be on its own to indicate the end of the whitespace tokenized group.  Can this be done using a single lexer/tokenizer, or would it be necessary to have a separate tokenizer when parsing this group?

答:
From what I see all it takes is making lexer to recognize opening brace and switching into greedy state. In such state you define new set of patterns, which are, well, greedy except for whitespaces. And single right brace has the effect of popping the state and going back to what was before.

The described approach would correctly tokenize both your examples.


答:
Try to do proper redesign while integrating new features. There is no later. Without the redesign you are constantly adding more and more friction for further changes and new features.

At some point you'll come to a grinding near halt where everything seems to take ages. Most companies probably go for the big rewrite at this point, version 2. It has pretty poor economics and is a good moment for your customer to try a different development party if they feel inclined.

Proper redesign/refactoring can protect your customers investment and keep things sustainable. You need to build this in. Optimize for change, travel light.


问:
Does it make sense to generate java classes from class diagram?
As we do design & analysis before development, wouldn't be convenient to be able to generate Java classes from a class diagram?

This would promote more exhaustive design and better codes, right?

It's strange that why Google returns tons of tools to generate class diagram from Java classes but not the other way around.

答:
No, it's much faster to write code than to draw diagrams on a computer.  To generate a Java class from a diagram you would have to draw the diagram, and then type in most of the code anyway.  Sure, you might not have to type get/set methods, but Lombok does a better job of solving that problem.  For example, it's much easier to simply type "class X implements Y" than it is to draw a box, type "X", and then connect X to Y with the right kind of arrow.  We have been experimenting with generating code from diagrams for decades now and except for a few very limited domains it hasn't been popular.

Also see this question.


答:
One major reason not mentioned by mavrosxristoforos is that Firefox, Chrome and Safari are all auto-updated software. So their users all have the latest version installed (except those who are never online. But well ...).

So the market share for older version is so small that it is irrelevant to consider anything but the latest one when developing a web application.

With Internet Explorer, users have to manually upgrade when a new version is out, which slows things a lot. So in order to reach some users, web applications have to be tested on older versions of IE.

Title: Why is Internet Explorer the only browser to be referred to by version when talking about compatibility?

Body:
Whenever I read something or hear someone talking about HTML5, CSS and JavaScript support, they always refer to Internet Explorer with the version number such as Internet Explorer 6, and Internet Explorer 9. But they only refer to Google Chrome, Firefox, Safari and others without version numbers.

Shouldn't they also specify the version number in which certain web technologies are incompatible for other browsers instead of just Internet Explorer?


答:
I think the last few years have shown a preference for using class diagrams to document existing code as opposed to generating code.

Diagrams give the reader of the code a quick look at the overall structure of the systems in terms of its classes and relationships.  Of course, the successful use of diagrams is dependent on the diagrams being kept in sync with the code; if they are not, then the diagrams are misleading.  This is why you see tools to generate diagrams from code.

Generating code from diagrams feels so 1990s.  It was popular in the Rational Rose days, but I don't see such tools being used so much anymore.  I for one can code much faster by typing (and yes, by using code-assist) than I can by making a diagram.  Even if you made a tool that made drawing class diagrams easy, would you expect most programmers to use it?  A class diagram can only get you so far.  You still have to write the code to implement the method bodies.  And what kind of software checks your diagrams for consistency?  What about importing classes from other packages?  Who can remember all the symbols for public, private, protected, package-private?  And how do we indicate static members with underlines in a convenient manner?  If a variable is initialized to a complicated expression, how do we enter this?  Even if it is entered, is there a compiler in the diagramming tool to check what we have?

And then, once the code is generated from the diagram, what are the chances that it is complete?  Do we still have to tweak more of it by hand?  If so, what if we find a mistake in the diagram?  Do we lose our hand edits?

The whole idea of generating code from pictures or diagrams seems like a misguided attempt to make software engineering like mechanical, electrical, or chemical engineering.  Or even architecture.  In those fields, your "blueprints" are paper designs and your product is manufactured by using the drawings.  Software is NOT like that.  In software, the source code IS the blueprint/design, while the product is the binary made by the compiler.

Of course, there is nothing wrong with making class diagrams as rough sketches at a conceptual level, but if there was any value in generating code from them, I would think that we would all be doing this by now.  (I know that last statement was not meant to be a deductive proof, but rather something that provides evidence for the claim, no?)

Title: Does it make sense to generate java classes from class diagram?

Body:
As we do design & analysis before development, wouldn't be convenient to be able to generate Java classes from a class diagram?

This would promote more exhaustive design and better codes, right?

It's strange that why Google returns tons of tools to generate class diagram from Java classes but not the other way around.


答:
The problem with Internet Explorer is that their major versions all require the at that time latest version of Windows.

The highest version on Windows XP is IE8

IE 9 requires Vista or Windows 7

IE 10 was initially only available for Windows 8 and is now also available for 7 but not for Vista.

IE 11 is preinstalled on Windows 8.1 only (there is a beta for 7, but you shouldn't expect normal users to use beta software)

Updating your Windows version costs money, time and sanity, so you can't blame the considerable amount of people who still use older versions of windows. That means they are also stuck with older versions of internet explorer.

But when it comes to other browsers which do not require a specific operating system, there is really no excuse to not use the latest version available.


答:
In some niche markets, where waterfall is king, class diagrams are required as part of the software design documentation.

In that case, generating code from diagrams makes sense.


答: Some programmers suggest that a way of controlling that problem with clients is to have client sign and authorize the initial specification. THEN, when they request a requirement change which is not in the initial spec, you tell them that you need to go through the contract and project timetable in order to calculate additional costs and time delays, then make an annex to the contract. Apparently it does wonders in preventing clients in insisting on new (unpredicted) features.</p>


答:
It sounds like your salespeople are creating a layer of miscommunication between your development teams and customers.  If they haven't been selling in the IT marketplace for a long time, they may view their role as 'move the product', meaning get a signature on a contract 'whatever it takes'.  In short, they're motivated to close, regardless of what they're promising.  In such circumstances they're going to track the language of the customer as closely as possible.

I'm a broken record quoting this, but here goes: you're on the operating table and as you're going under the surgeon says 'we'll have you out of here on time and within budget'.  Great.  Will I be alive?

If you are working on the internal organs of a business, do you stop at some arbitrary point? Typically an application is affected by forces neither you nor your client controls - regulations, business climate, competitor behavior, the emergence of some new paradigm, etc. If you simply say 'we will do 'thing x' for 'price y'' then the customer will come back three months later and say - 'well...'.  Generally meaning that they know something that they didn't know when you agreed to a waterfall project.

What might work in such a situation is demonstrating to your own sales staff what a drive through a canyon is like. At every turn there are surprises.  It isn't possible to see more than about three months out, so if a customer is asking for an 18 month project it will be unrecognizable by the time you're near completion.  Therefore your sales rep needs to start out by finding the financial payoff of the project.  Will this increase sales by $10 million?  If so, is it worth investing $2,000,000 to make that additional $10 million?  If the customer and sales rep are converging on a $500,000 commitment, then something might be wrong and no one can tell what it is - it just doesn't feel right.  What 'isn't feeling right' is a commitment to doing something that runs the risk of being useless.

The two latest jet airliner models have had a history of snafus. Healthcare.gov doesn't even need discussion. If you can find books or trade press stories on the airliners, you can bring up how certain assumptions were made that proved to be optimistic, and that the projects missed their deadlines repeatedly.  Often this was due to underestimating complexity.  If you can't really figure out how complex it is until you start coding it, you'll need an 'initial round' to get a better idea of the real problems.  The budget cutoff should be some fraction of the total additional profits (or revenues in some cases), and that number has to be more than anyone thinks the current project will cost.  If you can show how the last milestone can be passed without exceeding the 'payoff limit', it should be possible to sell the project as an agile effort.

Title: How to sell Agile development to (waterfall) clients

Body:
Our development shop would really like to do more agile projects but we have a problem getting clients on board. Many clients want a budget and a deadline. It's hard to sell a client on an agile project when our competitors do come up with waterfall-based fixed deadlines and fixed prices. We know their fixed numbers are bad, but the client doesn't know that. So, we end up looking bad to the client because we can't fix the price or a deadline but our competitors can.

So, how can you get your sales force to successfully sell a project that uses agile development methods, or a product that is developed using such methods? All the information I found seems to focus on project management and developers.


问:
License compatibility question
I have a question regarding software licenses. I plan to put a license to a framework that I have written. My intention is that the license should be open, in order to maintain a community.

To be clear I will explain how I expect things to work. The framework will define some common API for certain functionality as well as a Proxy class that will invoke an implementation of that API. The proxy will be part of the framework, but it will internally call an actual implementation which will be developed mostly by someone else.

So, basically I want to be able to:

Distribute my library as free and open-source

Allow use of my library in commercial software

Allow commercial products to depend on my library i.e. provide a derived work as long as it is a result of linking to my framework API (not using the source code directly in (un)modified form), and license their derived work as they choose.

Provide legal means of respecting the licenses of any third party implementations invoked trough my library.
This means a commercial application should be able to use my library an another commercial library designed to work with my library as long as it respects my licensing terms and those of the other commercial license.

答:
An addition to the existing answer here, and a simplified enough form for people getting to the licensing issue for the first time, here is a dedicated web site:

Choosing an OSS license doesn’t need to be scary - ChooseALicense.com

GitHub wants to help developers choose a license for their source code.

If you already know what you’re doing and have a license you prefer to use, that’s great! We’re not here to change your mind. But if you are bewildered by the large number of OSS license choices, maybe we can help...

This site is not a comprehensive directory of open source licenses. We think there are too many options, which adds to the confusion. On the homepage, we break it down into just three licenses. The vast majority of projects will likely be fine choosing from one of these three. Just in case you have specific needs not covered by those three, we also highlight a few other licenses to consider...

It contains a list of the most used licenses regarding source code (not only), and which usages are compatible with it.

Title: License compatibility question


答: We should know that what is being coded and where is it being written. So making an sketch before coding may be a good idea specially for beginners. It will let you be straight with your thoughts and can reduce the percentage of making errors. But if you are expert then there is no need for a diagram.</p>


答:
Trying to use Agile methods in a consultancy/bidding environment is very difficult when the customer is not on board.

If they are used to Waterfall style "here are our requirements, how much and how long will it take?" type projects, and are putting it out to tender there isn't really any time to convince them that Agile or any other way is better.

Agile has its advantage (and disadvantages of course), but quite frankly the customer often doesn't know or care about the detail behind the scenes.

They want 2 things - cost and time scale. And once you tell them that, they then want it cheaper and sooner. And you know what, we want it all. All the requirements. None can wait, or be chopped.

And as much as I dislike sales people in most walks of life, don't be too hard on the sales guys. That's a tough job.

They don't build software, they mostly have no idea how it all works past the buzz words.

Yet they have to come up with time scales and cost based on some woolly requirements meeting. Maybe they have some of the tech guys with them to reign them in, but they need to make a sale to keep things going.


问:
Just being hired as a senior developer, never even been a junior developer, what should I expect?
I've been a freelancer and a coder by night for a while, and recently, I've been hired after several levels of interviews in a nice NY company, even though I've some lacks in specific fields. Is this common for companies to hire seniors with less experience? Will they wait some weeks to respect a certain learning curve?

I don't know anything about working in a company, so that's why I worry. After one week, I'm still checking and exploring sources, but after one week of work, it seems that some coworkers are considering that I'm slow. I'm good in maths, physics, algorithms, but still I need to learn about all the templates used in this company.

Anyone here already received a less-experienced senior member in his team? Is this acceptable?

I'm planing on having a meeting with my boss to stop worrying about that. Sounds like a good idea?

[EDIT]

Thanks for these answers. I'm definitely a -new - senior developer. I returned to the office with more confidence on Monday. I guess that it's normal to feel a bit incompetent in front of unknown templates/sources during the first weeks when you receive a good pay.

答:
Even for people experienced in "working in companies", being on your toes is not necessarily a bad thing, it keeps you alert and focused. As long as you keep your confidence and don't get paralyzed.

It becomes easier. Working on a large code base, it's to be expected that you'll need time to familiarize yourself with its intricacies.
I had more than a decade on the clock working for a number of companies before I switched to development (a little over a year ago) and I still have moments of self-doubt when dealing with complex problems or daunting amounts of code (our code base line count runs in the many millions), but I just soldier on, keep Google, StackOverflow and this here web site open, work my butt off and I'm not too proud to ask for help. You're part of a team, no longer the lone coder at your home desk. Benefit from your colleagues' experience and knowledge.

You got hired after several levels of interviews, that means they made an informed choice by hiring you. Be cool, you got the job. That means there's already a level of trust in your abilities and you've been coding for a while now. You'll do fine.


问:
How should I start with Lisp?
I've been programming for years now, working my way through various iterations of Blub (BASIC, Assembler, C, C++, Visual Basic, Java, Ruby in no particular order of "Blub-ness") and I'd like to learn Lisp. However, I have a lot of intertia what with limited time (family, full time job etc) and a comfortable happiness with my current Blub (Java).

So my question is this, given that I'm someone who would really like to learn Lisp, what would be the initial steps to get a good result that demonstrates the superiority of Lisp in web development? Maybe I'm missing the point, but that's how I would initially see the application of my Lisp knowledge.

I'm thinking "use dialect A, use IDE B, follow instructions on page C, question your sanity after monads using counsellor D". I'd just like to know what people here consider to be an optimal set of values for A, B, C and perhaps D. Also some discussion on the relative merit of learning such a powerful language as opposed to, say, becoming a Rails expert.

Just to add some more detail, I'll be developing on MacOS (or a Linux VM) - no Windows based approaches will be necessary, thanks.

Notes for those just browsing by

I'm going to keep this question open for a while so that I can offer feedback on the suggestions after I've been able to explore them. If you happen to be browsing by and feel you have something to add, please do. I would really welcome your feedback.

Interesting links

Assuming you're coming at Lisp from a Java background, this set of links will get you started quickly.

Using Intellij's La Clojure plugin to integrate Lisp (videocast)

Lisp for the Web

Online version of Practical Common Lisp (c/o Frank Shearar)

Land of Lisp a (+ (+ very quirky) game based) way in but makes it all so straightforward

Install Clojure and Sublime 2 on MacOS an excellent getting started guide

Look at the Clojure in Action book. Worked for me.

答: I have a copy of ANSI Common Lisp right here by my desk. I pick it up every couple of years and get a couple of chapters through, then get stuck on a couple of exercises and it slips down the priority list. That probably tells you more about me than the book though. The book seems entirely competent...

Title: How should I start with Lisp?


问:
When should method overloads be refactored?
When should code that looks like:

```<code>DoThing(string foo, string bar);

DoThing(string foo, string bar, int baz, bool qux);

...

DoThing(string foo, string bar, int baz, bool qux, string more, string andMore);
</code>```

Be refactored into something that can be called like so:

```<code>var doThing = new DoThing(foo, bar);

doThing.more = value;
doThing.andMore = otherValue;

doThing.Go();
</code>```

Or should it be refactored into something else entirely?

In the particular case that inspired this question, it's a public interface for an XSLT templating DLL where we've had to add various flags (of various types) that can't be embedded into the string XML input.

答:
Both work, though I personally dislike assigning public members or properties like that if these members or properties are used directly for one purpose.

In other words, if you have a logger class, you shouldn't have to assign "logger.message" and then call "log()", since message is used strictly for the log method, hence it should be passed.

Understandably, I can see the need for doing such things in order to avoid refactoring code.  Here are a couple things you could do instead:

Consider passing non-specific parameters in the constructor rather than the method itself.  What I mean by non-specific parameters are parameters which aren't specific to a particular method but control behavior that isn't likely to change in the instance.  Returning to the logger class example, such a parameter might be the directory where the log file is saved.

Consider passing a key-value map containing all parameters.  This is the preferred method for passing non-descript parameters to third party libraries anyway.  If you find yourself dealing with large amounts of parameters to handle, then this might be preferable.    A good example of this might be instantiating a database connection using many of the database-specific parameters rather than having to have a static method for each database.  The method can then pull whatever parameters it finds that it can use.  However, I recommend that if you do it this way that you consider eliminating the other method signatures and forcing all calls to use this key-value system for consistency.

I hope that helps!


答:
I believe the common approach is to encapsulate some (or all) of the parameters into a class and have that as a parameter:

```<code>DoThing(string foo, string bar, DoThingParameters parameters = null);
</code>```

If you use C#, you can then write those parameters directly inline when calling the method:

```<code>DoThing(foo, bar, new DoThingParameters { More = value, AndMore = otherValue });
</code>```

Title: When should method overloads be refactored?

Body:
When should code that looks like:

```<code>DoThing(string foo, string bar);

DoThing(string foo, string bar, int baz, bool qux);

...

DoThing(string foo, string bar, int baz, bool qux, string more, string andMore);
</code>```

Be refactored into something that can be called like so:

```<code>var doThing = new DoThing(foo, bar);

doThing.more = value;
doThing.andMore = otherValue;

doThing.Go();
</code>```

Or should it be refactored into something else entirely?

In the particular case that inspired this question, it's a public interface for an XSLT templating DLL where we've had to add various flags (of various types) that can't be embedded into the string XML input.

Body:
I believe the common approach is to encapsulate some (or all) of the parameters into a class and have that as a parameter:

DoThing(string foo, string bar, DoThingParameters parameters = null);

If you use C#, you can then write those parameters directly inline when calling the method:

DoThing(foo, bar, new DoThingParameters { More = value, AndMore = otherValue });


问:
What would you do to improve the working of a small Development team?
My company is having a reshuffle and I'm applying for my boss' job as he's moved up the ladder. The new role would give me a chance to move our development team into the 21st century and I'd like to make sure that:

I can provide sensible suggestions in the interview to get the job so I can fix the team

If I get the job I can actually enact some changes to actually improve the lives of the developers and their output.

I want to know what I can suggest to improve the way we work, because I think it's a mess but every time I've suggested a change it's been shot down because any time spend implementing the change would be time that isn't spent developing software.

Here is the state of play at the moment:

My team consists of 3-4 developers (Mainly Java but I do some .Net
work)

Each member of the team is usually works on 2-3 projects at a time

We are each responsible for the entire life cycle of the project from design to testing.

Usually only one person works on a project (Although we have the odd project that will have more than one person working on it.)

Projects tend to be bespoke to single customer, or are really heavilly reliant on a particular customer environment.

We have 2-3 "Products" which we evolve to meet customer requirements.

We use SVN for source control

We don't do continuous integration (I'd like to start)

We use a really basic bug tracker for internal issue tracking (I'd like to move to an issue/task management system)

Any changes that bring a sudden dip in revenue generation will probably be rejected, the company isn't structured for development most of the rest of the technical team's jobs can be broken down to install this piece of hardware, configure that piece of hardware and once a job is done it's done and you never have to look at it again. This mentality has crept into development team because it's part of the company culture.

答:
You seem to have too grand ideas for your small team, but I would advice you start small and slowly work your way to incremental improvements in efficiency.

For example, whilst something like continuous integration would help you all improve the speed of your builds, and hopefully the quality of your releases, that's all it'll do becuase each team member works alone on a project at a time. Its worth the time spent implementing it solely to improve the standardisation and speed of your builds, not for any other reason given your team setup.

However, moving from a simply bug tracker to a full-blow task management solution would not help anyone. If each team member works alone, and has a bug allocated to him, does it really help him escalate a bug though statuses and update the owner and other fields? Does it help anyone else who is not going to look at his code?

You need to consider what improvements will really make a difference, not which improvements you'd like to make just because they're there to be made.

I would drop all the .net work, there's no point in having a single team member working with a different system. I'd probably work on some set of VMs to replicate customer environments so testing or development can be quicker to set up. I'd also look at managing the configuration sets that each customer has in some way.


答:
What do you use to build your products? If you use ANT or Maven for example, there are numerous plug-ins/tasks such as checkstyle that you can use to enforce coding standards.

Having one person per product is highly undesirable. Do you do peer code reviews? This could be one way of exposing the other developers to the other products. At the very least I would suggest knowledge transfer sessions, to ensure if you suddenly lose a developer they don't take all knowledge of the product with them!

Title: What would you do to improve the working of a small Development team?

Body:
My company is having a reshuffle and I'm applying for my boss' job as he's moved up the ladder. The new role would give me a chance to move our development team into the 21st century and I'd like to make sure that:

I can provide sensible suggestions in the interview to get the job so I can fix the team

If I get the job I can actually enact some changes to actually improve the lives of the developers and their output.

I want to know what I can suggest to improve the way we work, because I think it's a mess but every time I've suggested a change it's been shot down because any time spend implementing the change would be time that isn't spent developing software.

Here is the state of play at the moment:

My team consists of 3-4 developers (Mainly Java but I do some .Net
work)

Each member of the team is usually works on 2-3 projects at a time

We are each responsible for the entire life cycle of the project from design to testing.

Usually only one person works on a project (Although we have the odd project that will have more than one person working on it.)

Projects tend to be bespoke to single customer, or are really heavilly reliant on a particular customer environment.

We have 2-3 "Products" which we evolve to meet customer requirements.

We use SVN for source control

We don't do continuous integration (I'd like to start)

We use a really basic bug tracker for internal issue tracking (I'd like to move to an issue/task management system)

Any changes that bring a sudden dip in revenue generation will probably be rejected, the company isn't structured for development most of the rest of the technical team's jobs can be broken down to install this piece of hardware, configure that piece of hardware and once a job is done it's done and you never have to look at it again. This mentality has crept into development team because it's part of the company culture.


答:
We set up 2 or 3 estimation sessions with the potential customer and our developers where we discuss the work at hand and set the acceptance criteria. The developers estimate the work in story points during the meeting.

Afterwards we sell the customer a number of story points. This is possible because he has a good idea of the value of the story points. We tell him that he has the possibility to fine tune his backlog/scope during the project and that it will be easy due to the use of the story points. We also tell him that there will be a frequent delivery of working software so that he can monitor the progress and get new insights.

By agreeing on a number of story points the customer is guaranteed to get value for his money. If he doesn't change his backlog he has his fixed price/fixed scope project, but my experience is that he will make changes. By doing the estimations in the presence of the potential customer we try to build a relationship based upon openness and trust.

We managed to convince clients like you describe, who "want a budget and a deadline", and they were happy we wanted to really understand what they needed, instead of working from a document. We showed that we wanted to invest in these projects.

During the estimation sessions we estimated their entire backlog. This gave x story points. We suggested to add 25% for those features that weren't yet clear or known at the time. With the estimated backlog attached to the contract they were reassured that they would get everything for the fixed budget.

Originally the bid was time and material. As they wanted to have a fixed price bid, we suggested to work for the price we gave them and use the 25% extra story points for contingency. If things went well, the part of the 25% that was not used to cover the delays we encountered would be used to deliver more functionality for the customer.

This stimulated them in a number of ways: first, they did everything they could to enable our developers to work as fast as possible, as this was clearly in their own interest. We never had to wait for answers to questions. Secondly, they really understood the concept of the story points. Before the project started, they had already removed some of the stories and asked us to estimate other stories. No complicated contract negotiations were needed for this.

We kept them informed of the progress and kept a very open communication. They got a progress report every 2 weeks: x % of the story points done in y % of the estimated time leaves z % of the extra story points available. We had a bit of a difficult start but managed to catch up with the estimates by the end of the project, which left 100 % of the extra story points available for extra development. The customer was happy because he got everything he really needed (and that was a bit different from his initially requested features, he removed some and added others).

The customer was also happy because everything was delivered in the foreseen timeframe (where he also did everything possible to help us like chasing tickets, answering questions immediatly, involving the users in weekly analysis meetings and also involving them in functional testing).

My company was happy because we delivered in time and on budget. My company was also happy because the success of this project opened the door for more projects. We even got mentioned in the monthly magazine of the customer that was sent to people worldwide.

Doing good estimates was the most difficult part of the project, but having the estimation sessions up front helped us to understand the difficulty and the risks. It enabled us to give an estimate based upon facts and removed a lot of the unknowns.


答:
1) I would recommend picking up GIT as a version control system, the logic behind this is that its a distributed version control system opposed to a regular version control system. This basically means that the developers can commit locally as much as they want without pushing up to the remote repo, this not only helps developers commit more frequently and have more control over their merging and branching, but also gives additional redundancy as if the main server goes down you can rebuild it from peoples repos.

See more about the topic here:
https://stackoverflow.com/questions/871/why-is-git-better-than-subversion

2) I would adopt CI as quickly as possible, makes your life a lot simpler. I tend to use Teamcity and Youtrack, as they are both free and brilliant tools which are robust and easy to setup and manage. You can then have it so a developer can commit in GIT (or SVN) having a message like:

```<code>#task-1 Fixed
Done something to fix task 1
</code>```

Which would then get pulled through into TeamCity which would automatically run your build script (assuming it contains steps to template files, compile, test, package) then would integrate with YouTrack allowing that issue to be updated on the Agile Board (you dont have to be agile to use the benefits of the board). So you have a COMPLETE development eco-system where you can see for every commit, why it happened, what it was and what was changed, or even look at a bug/tasks history to see who worked on it when.

3) Use environmental build scripts if you dont already, something like RAKE (and Albacore for .net) will get you up and running. You can then have it so a developer checks out a project from GIT (or SVN) and runs a build script/batch file which will setup the developers IIS/Apache servers, their configuration files, the database etc. This way you can make sure all developers can teardown and setup their environments easily and get up and running with projects quickly, but also you can use this same build script on your CI server in the previous step. You ideally want the generic scripts for stuff like template, compile, setup web server, setup database, unit tests, integration tests etc, then a set of specific properties/config files describing each environment, so dev would have configurations to use Database Server A and Web Server B, whereas live environment may use Database Server Z and Web Servers C and D.

4) If you dont already do so, train up on automated testing. Mainly on unit testing and mocking, then integration testing and acceptance testing. If you are a web house go look into selenium/webdriver and how you can automate your browser testing. This can then be run on your build server to prove that a commit has not broken the server (assuming you use a build script).

5) Try to make some sort of shared knowledge repository, it sounds like everyone is a knowledge silo there, so if there is an issue with Project A, only Developer A can look at it. So if Developer A manages Project A, F, H, J and walks from the company you will then have 4 unknowns. So install a wiki or some other tool which will allow you to collate information so people can give an overview of each project and the quirks and setup instructions etc, if you combine this with the automated tests and build scripts almost any developer can pick up the project, build it, test it and see what needs to be fixed etc.

Hope that helps

Body:
1) I would recommend picking up GIT as a version control system, the logic behind this is that its a distributed version control system opposed to a regular version control system. This basically means that the developers can commit locally as much as they want without pushing up to the remote repo, this not only helps developers commit more frequently and have more control over their merging and branching, but also gives additional redundancy as if the main server goes down you can rebuild it from peoples repos.

See more about the topic here:
https://stackoverflow.com/questions/871/why-is-git-better-than-subversion

2) I would adopt CI as quickly as possible, makes your life a lot simpler. I tend to use Teamcity and Youtrack, as they are both free and brilliant tools which are robust and easy to setup and manage. You can then have it so a developer can commit in GIT (or SVN) having a message like:

#task-1 Fixed
Done something to fix task 1

Which would then get pulled through into TeamCity which would automatically run your build script (assuming it contains steps to template files, compile, test, package) then would integrate with YouTrack allowing that issue to be updated on the Agile Board (you dont have to be agile to use the benefits of the board). So you have a COMPLETE development eco-system where you can see for every commit, why it happened, what it was and what was changed, or even look at a bug/tasks history to see who worked on it when.

3) Use environmental build scripts if you dont already, something like RAKE (and Albacore for .net) will get you up and running. You can then have it so a developer checks out a project from GIT (or SVN) and runs a build script/batch file which will setup the developers IIS/Apache servers, their configuration files, the database etc. This way you can make sure all developers can teardown and setup their environments easily and get up and running with projects quickly, but also you can use this same build script on your CI server in the previous step. You ideally want the generic scripts for stuff like template, compile, setup web server, setup database, unit tests, integration tests etc, then a set of specific properties/config files describing each environment, so dev would have configurations to use Database Server A and Web Server B, whereas live environment may use Database Server Z and Web Servers C and D.

4) If you dont already do so, train up on automated testing. Mainly on unit testing and mocking, then integration testing and acceptance testing. If you are a web house go look into selenium/webdriver and how you can automate your browser testing. This can then be run on your build server to prove that a commit has not broken the server (assuming you use a build script).

5) Try to make some sort of shared knowledge repository, it sounds like everyone is a knowledge silo there, so if there is an issue with Project A, only Developer A can look at it. So if Developer A manages Project A, F, H, J and walks from the company you will then have 4 unknowns. So install a wiki or some other tool which will allow you to collate information so people can give an overview of each project and the quirks and setup instructions etc, if you combine this with the automated tests and build scripts almost any developer can pick up the project, build it, test it and see what needs to be fixed etc.

Hope that helps


答:
A very pragmatic approach: Yes, there is a plethora of licenses around, but unless you really care about some specific license detail, I would recommend to use either the GPL v3 or the revised BSD/MIT license. The basic question you should ask yourself is:

Do you want to allow others to take your code and use it in closed-source projects?

If yes, I would recommend the revised BSD license.

If no, I would recommend the GPL v3.

All your concerns about controlling release and so on are not really related to the license; if you are the maintainer of your version, you can control the official releases.

Title: License compatibility question

Body:
I have a question regarding software licenses. I plan to put a license to a framework that I have written. My intention is that the license should be open, in order to maintain a community.

To be clear I will explain how I expect things to work. The framework will define some common API for certain functionality as well as a Proxy class that will invoke an implementation of that API. The proxy will be part of the framework, but it will internally call an actual implementation which will be developed mostly by someone else.

So, basically I want to be able to:

Distribute my library as free and open-source

Allow use of my library in commercial software

Allow commercial products to depend on my library i.e. provide a derived work as long as it is a result of linking to my framework API (not using the source code directly in (un)modified form), and license their derived work as they choose.

Provide legal means of respecting the licenses of any third party implementations invoked trough my library.
This means a commercial application should be able to use my library an another commercial library designed to work with my library as long as it respects my licensing terms and those of the other commercial license.


问:
What is the right level of site blocking for you as a developer?
Almost all developers who work for a large corporation find themselves on the wrong side of site blocking software. It can be both frustrating ("Just let me read that damn blog!") and helpful ("Woah! Dodged a bullet with that site").

In your opinion, what is the right level of blocking to apply to developers and why?

答: They can block all they want, I'll just use my smartphone.</p>


问:
What happens with project backlog if sprint due date is missed?
Suppose that I have project backlog item with effort of 40 hours. My sprint is 40 hours (1 week) and I have one developer in team.

So developer creates child task to pending backlog and estimates work to 40 hours. At the end of the sprint developer didn't succeed in resolving his task. Suppose that developer works only and only 40 hours per week.

On the next week there would be new backlog items and new sprint. What should I do with backlog item and velocity graph?

Obviously backlog item is not resolved on that sprint. Should I estimate the remaining work and subtract it from effort , so that now I see that our velocity is, say, 38hr per 40hr sprint?

答:
I would say your story is too big and would require cutting down into smaller tasks. Generally in agile teams I have worked with we tend to do as much as we can in the sprint, anything not finished just goes on the backlog to be re-prioritized for the next sprint, as you may not want to play them in the next sprint.

If you have the case of a story where it is partially done in a sprint, but not entirely you need to make the call if the tasks (assuming you have some task level items under a story) are complete and if so can they be safely left in the live code base. If so the next time that story is played the developer working on it will see that 5 of the 7 tasks are complete and pick up where the other developer left off. If it is not stable enough to be put in, you can either scrap it and let someone else start fresh, or park it in another branch for the developer to resume in another sprint when it is needed. Although working this way would require developers to manage their stories as branches in the source control system.


答:
So your boss got a promotion, I guess he (at least partly) will be involved in the application process for a new boss.

Your boss probably(/hopefully) got promoted because he did a good job. That means that your current process is working and is profitable. You need to recognize the strengths of the current model.

Also, the "I want to change everything since it's broken" will probably not get you the job if the old boss is part of the hiring, since this will mean that you indirectly call his work for broken (he has run the team this way and he got a promotion). Actually, he has turned down many of your ideas and that lead him to a promotion. That means, your ideas was wrong. (Not wrong in a technical sense but in the eyes of the company, which is the only thing that matters).

You should not try to "fix the team". You should improve your deliverables. For example, reducing the buss factor would make it possible for you to deliver all year around, that would reduce the revenue dip during vacations (that you talked about).

Take small steps in the direction you want.

If we assume that your boss did a bad job and have accumulated a technical debt you should ask yourself if you really want the job. This debt will somehow show itself in the future and then it most likely will be seen as the fault of the new boss.

If this is true and you get the job you'll need to do huge changes to the process without management support. That's almost impossible. You need to take small steps that adds value and you'll need to work hard on your leadership to be able to lead your team through changes. I actually don't think this is a technical question at all and maybe you'll get a better answer in the management section of Stack Exchange.

Remember that as a developer you had the freedom of choosing or want to choose the technical best approach. As a boss you have more factors to account for and the technical best solution does not have to be the best solution over all (for example, the benefits of switching to git may be spoiled by the education your team will need).

To try to answer the technical aspect of your question:

Improve the bus factor by never letting anyone work alone on a project. There's several ways you can do that, for example with pair-programming or code-reviews. Find a way that fits your team.

Make sure your products are maintained longterm. The usual way for this is to have a "product owner" for each product which will be in charge of the longterm development of that product. This will reduce technical debt and make sure that changes done to one clients codebase is backported to the main codebase for the next customer.

review your tools. You might benefit from the improved branching and merging features of a DVCS instead of SVN, but it's not sure. Specially not if your team is comfortable with svn but not with dvcs. Do a review of all your tools, .NET, java, svn, bug/ticket-system. One at a time!

How can you improve your responsiveness to customers need? Can you use some type of CRM system to improve your customer relationship?


答:
Agile doesn't preclude deadlines and budgets. If I was a client and I went to a developer and they told me that they couldn't give me a deadline or an estimated cost, I'd question their sanity. And telling them that they just don't understand isn't going to work: they need to be able to budget and plan.

They don't need to know your development process. They need to know how long it's going to take to develop features and how much its going to cost. Give them a number based on the (spurious) assumption that their requirements are 100% accurate, and when their requirements change, then change your estimates.

This gives them the budget line items and deployment dates they want, and when things change, your process lets you look flexible and accommodating.


答:
I prefer to not recognize any of the effort in my velocity unless we've achieved "Done".  My preference is to show velocity of value delivered, and a partially working but incomplete solution that doesn't achieve the goal of the story doesn't deliver the value that was estimated.

So the 'value' is the same, rolls over to the next iteration, but the estimate for task hours remaining may need to be adjusted.  In fact, I usually only suggest to my team to track task hours remaining for the burndown.

The next sprint, when the work reaches "Done", we recognize the full value award, and the task hours remaining should get to zero.

Title: What happens with project backlog if sprint due date is missed?

Body:
Suppose that I have project backlog item with effort of 40 hours. My sprint is 40 hours (1 week) and I have one developer in team.

So developer creates child task to pending backlog and estimates work to 40 hours. At the end of the sprint developer didn't succeed in resolving his task. Suppose that developer works only and only 40 hours per week.

On the next week there would be new backlog items and new sprint. What should I do with backlog item and velocity graph?

Obviously backlog item is not resolved on that sprint. Should I estimate the remaining work and subtract it from effort , so that now I see that our velocity is, say, 38hr per 40hr sprint?


答:
There are some good thoughts in the other answers, particularly @gbjbaanb.  However, I can't help but think that something is missing from the question.  What are the problems that the team has currently? What is preventing the team from fully contributing to the success of the business?

Not doing continuous integration isn't a problem, unless it is preventing the team from delivering in a high quality way.  The absence of a task management system isn't a problem unless the team is losing track of tasks or is having difficulty communicating status.  These are good practices, that probably won't hurt, but if they aren't addressing the things that are keeping the team from succeeding directly, the management won't be interested.

Your starting point should be a diagnosis of where the problems in delivery exist and where opportunities for better contribution to the success of the company exist.  Ask yourself the following questions:

Can the team help the business grow? What is the management team trying to accomplish with the part of the business that does software development?  Are they trying to expand the team? Are they trying to sell more complex, larger projects? Is there some overarching goal that can't be met because of the maturity of the development team?

Are there currently delivery problems that are interfering with the success of the business? What are the biggest problems you have from a delivery perspective? Does the team miss deadlines? Do they get the requirements wrong? What do your clients think about the quality of the work being delivered? Is the team able to be responsive to changing customer needs?

Depending on the answers to these questions, you will get a sense of what problems are important to address first, and where there is opportunity to contribute to the growth of the company.  There are a few different ways that this could play out.  Here are some examples:

One common problem is a lack of transparency - i.e., the customer doesn't know how the system is shaping up until it is almost done and then they are disappointed with the result.  A solution to this could be a deploying more frequently throughout the development cycle and exposing the in progress work to the customer.  CI could help by ensuring that there is always a working version of the build and minimizing integration headaches between these deployments, but the key in this case is getting software in front of customers often and early.

It could well be that the team is just writing bad code that is hard to maintain and difficult to fix.  In this case, CI and task tracking, for example, don't really help much. You probably do need collaboration across the team and perhaps code reviews to ensure quality.  In this case some focus on educating the team on best practices for writing quality code would also help.

You mention that people are responsible for their own QA. This seems like a potential red flag. Is testing automated?  Could this help reduce manual QA effort?  Might it be better to have a dedicated QA person responsible for integration testing before code gets to customers?

All, or none, of these problems might exist in your environment.  The point is that there is no set of improvements that make sense in any and all environments. You need to be driven by the specific challenges that exist at your company.  Any of the so called "best" practices mentioned above can help, but they can also be wasted effort and money if you are addressing problems that don't exist.


问:
Type checking and recursive types (Writing the Y combinator in Haskell/Ocaml)
When explaining the Y combinator in the context of Haskell, it's usually noted that the straight-forward implementation won't type-check in Haskell because of its recursive type.

For example, from Rosettacode:

The obvious definition of the Y combinator in Haskell canot be used
because it contains an infinite recursive type (a = a -> b). Defining a data type (Mu) allows this recursion to be broken.

```<code>newtype Mu a = Roll { unroll :: Mu a -> a }

fix :: (a -> a) -> a
fix = \f -> (\x -> f (unroll x x)) $ Roll (\x -> f (unroll x x))
</code>```

And indeed, the “obvious” definition does not type check:

```<code>λ> let fix f g = (\x -> \a -> f (x x) a) (\x -> \a -> f (x x) a) g

<interactive>:10:33:
    Occurs check: cannot construct the infinite type:
      t2 = t2 -> t0 -> t1
    Expected type: t2 -> t0 -> t1
      Actual type: (t2 -> t0 -> t1) -> t0 -> t1
    In the first argument of `x', namely `x'
    In the first argument of `f', namely `(x x)'
    In the expression: f (x x) a

<interactive>:10:57:
    Occurs check: cannot construct the infinite type:
      t2 = t2 -> t0 -> t1
    In the first argument of `x', namely `x'
    In the first argument of `f', namely `(x x)'
    In the expression: f (x x) a
(0.01 secs, 1033328 bytes)
</code>```

The same limitation exists in Ocaml:

```<code>utop # let fix f g = (fun x a -> f (x x) a) (fun x a -> f (x x) a) g;;
Error: This expression has type 'a -> 'b but an expression was expected of type 'a
       The type variable 'a occurs inside 'a -> 'b
</code>```

However, in Ocaml, one can allow recursive types by passing in the -rectypes switch:

```<code>   -rectypes
          Allow  arbitrary  recursive  types  during type-checking.  By default, only recursive
          types where the recursion goes through an object type are supported.
</code>```

By using -rectypes, everything works:

```<code>utop # let fix f g = (fun x a -> f (x x) a) (fun x a -> f (x x) a) g;;
val fix : (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b = <fun>
utop # let fact_improver partial n = if n = 0 then 1 else n*partial (n-1);;
val fact_improver : (int -> int) -> int -> int = <fun>
utop # (fix fact_improver) 5;;
- : int = 120
</code>```

Being curious about type systems and type inference, this raises some questions I'm still not able to answer.

First, how does the type checker come up with the type t2 = t2 -> t0 -> t1? Having come up with that type, I guess the problem is
that the type (t2) refers to itself on the right side?

Second, and
perhaps most interesting, what is the reason for the Haskell/Ocaml
type systems to disallow this? I guess there is a good reason
since Ocaml also will not allow it by default even if it can deal
with recursive types if given the -rectypes switch.

If these are really big topics, I'd appreciate pointers to relevant literature.

答:
In OCaml, you need to pass -rectypes as a parameter to the compiler (or enter #rectypes;; in the toplevel). Roughly speaking, this will turn off "occurs check" during unification. The situation The type variable 'a occurs inside 'a -> 'b will no longer be a problem. The type system will still be "correct" (sound, etc.), the infinite trees that arise as types are sometimes called "rational trees". The type system gets weaker, i.e. it becomes impossible to detect some programmer errors.

See my lecture on lambda-calculus (starting at slide 27) for more information on fixpoint operators with examples in OCaml.

ContentLicense: CC BY-SA 4.0


答:
I am now more or less in the position you're applying for. It's not even been six months so I lack the experience to give you a truly wise advice, but here is what I have learned so far.

First and foremost,

You need to be patient

There are always plenty of broken things we want to get fixed right away. But you can only allocate this much amount of resources to it, changing things mean it will take time to get used to it, and changing to many things at the same time might alienate your team.

This being said,

You want continuous integration

You, your team, your hierarchy, your customers, you all want continuous integration. Even if some of you don't think so. Set up a build server with incremental builds, nightly builds, documentation generation, automatic tests, direct access to the latest stable package, and you will make their day.

You want to get rid of anything that wastes time

Your team should be spending their time doing great stuff. But most likely, they spend a sizable amount of it doing something totally unproductive. Identify all the things that steal time from them, things they should not have to do, things a machine could do, things that should not be done more than once, and fix them. You're one of them, you know where time is wasted and what they really want to be doing, right?

That build process that takes a dozen steps that you just "have to know"? Get it done by a script once and for all. For some reason it cannot be fully automated (yet), document it!

That compilation that takes two hours to complete? Do what it takes to reduce it to an acceptable amount of time: chop it, profile it, assign a task to someone, but don't let your team stare at compiling screens.

That one issue that keeps coming back every other month and each time takes half a day to figure out? Get it fixed, really fixed, write tests for it, and make sure the test is run automatically with every new build (I'm not even talking about TDD here, simply regression testing and automated tests).

That project you're working on that takes 5 minutes to launch? Take the few hours it takes to identify the bottleneck and get it to launch in a flash. While you're at it, why relaunching when you can simply reload the data!

That workstation that takes ten minutes to boot in the morning? Give it RAM, give it an SSD, give whatever it takes so it doesn't waste hours of engineers time when a hundred bucks would cut it.

That server that takes so much time to handle your requests you're seriously wondering if it's not sequencing DNA? Get someone to identify the problem.

Those people who keep coming several times a day with incomplete half-thought requests that were not even validated yet? Tell them to come to you or to one person in particular, but don't let them interrupt your team's work. Shade them from these annoying distractions, from irrelevant details, and give them well processed information they can work with.

That bunch of documents spread all over the intranet that nobody ever knows where to find or which version to use? Get it all in a same place (or at least referenced in a same place), dated, with a version and a contact.

Your hierarchy will frown upon some of these ideas, but here one of your best arguments is the technical debt metaphor. Also recognize what doesn't need to be changed though: "If it ain't broke, don't fix it." Or put differently, "Is it worth the time?"

See also:
How can I convince management to deal with technical debt?

You don't want to get too crazy

Your team is small, so no need to hammer them with overly complicated processes. Hey the point was to get stuff out of their way! And again, be patient, bring one change at a time and let it sink in, and fine tune the wheels until it runs smoothly.

Since your team is small, you can also experiment. Once you've identified a specific problem you want to nail (say, the bug tracker is too cumbersome for example), see what solutions are available to you (bugzilla, Redmine, Trac, Atlassian, Trello, old fashioned white-board...), then try one, maybe only for yourself, maybe with just another team member, see how it works, how it's accepted, and adapt. The solution turns out to be uneasy? Try something else. Is it better? Good stick with it.

These were my two cents on the topic. As I said, I'm quite new to this too, so people who know better are very welcome to comment. :)


问:
The Agile process: how and what should be documented?
A while ago the company I work for had outsourced a development project to a third party. They employed agile practices in developing the solution. However when asked for documentation they would just say it was required as it was incorporated in a wiki or as part of their sprints.

They did leave at the completion of the project, with all but one of the project team. The project wiki site has now been closed down once the yearly subscription was due.

When they left they took most of the knowledge and understanding of what was developed with them.

So I do have 2 main questions;

Is this normal for agile or just an excuse for not wanting to write it?

What are the industry norm for documentation in agile projects to record development
requirements, designs, key decisions and context?

答:
In my experience there are always a lot of people demanding documentation (I've been one of them) but in practice noone really has time or desire to create them. Occasionally there are efforts, but the documentation created typically gets outdated very quick and gets out of sync with the real functioning of the system.
This leads to a situation where even if you do have documentation noone really bothers checking it cause they simply don't trust it's accuracy.

For real accuracy and reliable information it pretty much comes down to being able to read code and tests. A customer wanting to (re)discover what his system does can always interview and query a programmer who can then present (with some investigation) facts about the system.

Creating good documentation is -not- trivial and can be quite costly. Secondly one could wonder about the audience, who is the documentation for and what is it intended to provide?


问:
Validating data to nest if or not within try and catch
I am validating data, in this case I want one of three ints. I am asking this question, as it is the fundamental principle I'm interested in. This is a basic example, but I am developing best practices now, so when things become more complicated later, I am better equipped to manage them.

Is it preferable to have the try and catch followed by the condition:

```<code>public static int getProcType()
{
    try
    {
        procType = getIntInput("Enter procedure type -\n"
            + " 1 for Exploratory,\n"
            + " 2 for Reconstructive, \n"
            + "3 for Follow up: \n");
    }
    catch (NumberFormatException ex)
    {
        System.out.println("Error! Enter a valid option!");
        getProcType();
    }
    if (procType == 1 || procType == 2 || procType == 3)
    {
        hrlyRate = hrlyRate(procType);
        procedure = procedure(procType);
    }
    else
    {
        System.out.println("Error! Enter a valid option!");
        getProcType();
    }

    return procType;
}
</code>```

Or is it better to put the if within the try and catch?

```<code>public static int getProcType()
{
    try
    {
        procType = getIntInput("Enter procedure type -\n"
            + " 1 for Exploratory,\n"
            + " 2 for Reconstructive, \n"
            + "3 for Follow up: \n");

        if (procType == 1 || procType == 2 || procType == 3)
        {
            hrlyRate = hrlyRate(procType);
            procedure = procedure(procType);
        }
        else
        {
            System.out.println("Error! Enter a valid option!");
            getProcType();
        }
    }
    catch (NumberFormatException ex)
    {
        System.out.println("Error! Enter a valid option!");
        getProcType();
    }

    return procType;
}
</code>```

I am thinking the if within the try, may be quicker, but also may be clumsy. Which would be better, as my programming becomes more advanced?

答:
I wouldn't bother using an exception.  Instead just a simple test on an IF condition on the method/function.

As @gnat says, putting this in a seprate merthod/function is the best.  Also, consider adding an enumeration for the return with an extra value like:

```<code> Exploratory,
 Reconstructive,
 FollowUp,
 Undefined
</code>```

So, when getProcType() is called it can return "Undefined" back.  If your program gets that display a message to the user and then quit.  If it gets a proper value, it continues and calls another method to call the hourly rate and procedure (separate method).

In your code, how does the user cancel out?  They could get stuck trying to enter 1,2,3 as the function keeps calling itself.  It usually better to fail fast.  So, politely tell the user they entered the wrong value, display a list of acceptable values and then quit.  I'm assuming this is some sort of command line utility.

Also, I can suggest using a more sophisticated UI like a list box/combo box which would eliminate having the user typing anything.  Then this logic would not be needed at all.  In general we want to avoid having the using type in things whenever possible.

Body:
I wouldn't bother using an exception.  Instead just a simple test on an IF condition on the method/function.

As @gnat says, putting this in a seprate merthod/function is the best.  Also, consider adding an enumeration for the return with an extra value like:

 Exploratory,
 Reconstructive,
 FollowUp,
 Undefined

So, when getProcType() is called it can return "Undefined" back.  If your program gets that display a message to the user and then quit.  If it gets a proper value, it continues and calls another method to call the hourly rate and procedure (separate method).

In your code, how does the user cancel out?  They could get stuck trying to enter 1,2,3 as the function keeps calling itself.  It usually better to fail fast.  So, politely tell the user they entered the wrong value, display a list of acceptable values and then quit.  I'm assuming this is some sort of command line utility.

Also, I can suggest using a more sophisticated UI like a list box/combo box which would eliminate having the user typing anything.  Then this logic would not be needed at all.  In general we want to avoid having the using type in things whenever possible.


答:
If you take a look at a site like http://caniuse.com/ you can see a breakdown of support for various HTML/CSS/etc features by version number of all the browsers.

That might give you a better visual picture of why IE is generally referred to by number while the others aren't.

For example, here is a chart which shows support levels for Drag and Drop in various browsers:


问:
Should we rename overloaded methods?
Assume an interface containing these methods :

```<code>Car find(long id);

List<Car> find(String model);
</code>```

Is it better to rename them like this?

```<code>Car findById(long id);

List findByModel(String model);
</code>```

Indeed, any developer who use this API won't need to look at the interface for knowing possible arguments of initial find() methods.

So my question is more general :
What is the benefit of using overloaded methods in code since it reduce readability?

答:
Favor overloading as long as the methods return the same thing and follow the same contract.
Overloading frees the calling code from committing unnecessarily to the parameter type.

Suppose the calling function receives a search query as a parameter and performs some other processing before and/or after the call to find.

```<code>void tryToSellCars(String which) {
    /* grab an airhorn, inflatable tube guy... */
    List<Car> cars = find(which);
    /* expound virtues of each car in detail... */
}
</code>```

If you want to change the type of that query for whatever reason down the road (for instance from a simple ID string to a fully-featured query object of some sort) you can make that change in the calling function just by changing the function signature to accept the new parameter type without worrying about changing the method it calls on your class.

```<code>void tryToSellCar(CarQuery which) {
    /* grab airhorn, inflate tube guy... */
    List<Car> cars = find(which)
    /* expound virtues of each car in detail... */
}
</code>```

If you implement findById and findByQueryObject separately, you would have to hunt down every call to make that change.  In the example, I only changed one word and I was done.

Title: Should we rename overloaded methods?

Body:
Favor overloading as long as the methods return the same thing and follow the same contract.
Overloading frees the calling code from committing unnecessarily to the parameter type.

Suppose the calling function receives a search query as a parameter and performs some other processing before and/or after the call to find.

void tryToSellCars(String which) {
    /* grab an airhorn, inflatable tube guy... */
    List<Car> cars = find(which);
    /* expound virtues of each car in detail... */
}

If you want to change the type of that query for whatever reason down the road (for instance from a simple ID string to a fully-featured query object of some sort) you can make that change in the calling function just by changing the function signature to accept the new parameter type without worrying about changing the method it calls on your class.

void tryToSellCar(CarQuery which) {
    /* grab airhorn, inflate tube guy... */
    List<Car> cars = find(which)
    /* expound virtues of each car in detail... */
}

If you implement findById and findByQueryObject separately, you would have to hunt down every call to make that change.  In the example, I only changed one word and I was done.


问:
How to read thousands lines of code without any documentation?
Previously I was searching for a good TimeLine control for a WPF project. I found an answer in Here which direct me to this CodePlex project.

Now I want to change code to feed my culture needs. But there are some mismatches!

My question is:

How you interact with such thousands lines of code?

EDIT:

Any shortcut will be great!

答: Draw diagrams of the source: the data relationships, the functional relationships, the object relationships.  Determine aggregation, data flow, and code flow.  Pictures are far better than comments for this, and can be kept separate from the code.</p>


问:
Is linq more efficient than it appears on the surface?
If I write something like this:

```<code>var things = mythings
    .Where(x => x.IsSomeValue)
    .Where(y => y.IsSomeOtherValue)
</code>```

Is this the same as:

```<code>var results1 = new List<Thing>();
foreach(var t in mythings)
    if(t.IsSomeValue)
        results1.Add(t);

var results2 = new List<Thing>();
foreach(var t in results1)
    if(t.IsSomeOtherValue)
        results2.Add(t);
</code>```

Or is there some magic under the covers that works more like this:

```<code>var results = new List<Thing>();
foreach(var t in mythings)
    if(t.IsSomeValue && t.IsSomeOtherValue)
        results.Add(t);
</code>```

Or is it something completely different altogether?

答:
LINQ queries are lazy. That means the code:

```<code>var things = mythings
    .Where(x => x.IsSomeValue)
    .Where(y => y.IsSomeOtherValue);
</code>```

does very little. The original enumerable (mythings) is only enumerated when the resulting enumerable (things) is consumed, e.g. by a foreach loop, .ToList(), or .ToArray().

If you call things.ToList(), it is roughly equivalent to your latter code, with perhaps some (usually insignificant) overhead from the enumerators.

Likewise, if you use a foreach loop:

```<code>foreach (var t in things)
    DoSomething(t);
</code>```

It is similar in performance to:

```<code>foreach (var t in mythings)
    if (t.IsSomeValue && t.IsSomeOtherValue)
        DoSomething(t);
</code>```

Some of the performance advantages of the laziness approach for enumerables (as opposed to calculating all the results and storing them in a list) are that it uses very little memory (since only one result is stored at a time) and that there's no significant up-front cost.

If the enumerable is only partially enumerated, this is especially important. Consider this code:

```<code>things.First();
</code>```

The way LINQ is implemented, mythings will only be enumerated up to the first element that matches your where conditions. If that element is early on in the list, this can be a huge performance boost (e.g. O(1) instead of O(n)).

Body:
LINQ queries are lazy. That means the code:

var things = mythings
    .Where(x => x.IsSomeValue)
    .Where(y => y.IsSomeOtherValue);

does very little. The original enumerable (mythings) is only enumerated when the resulting enumerable (things) is consumed, e.g. by a foreach loop, .ToList(), or .ToArray().

If you call things.ToList(), it is roughly equivalent to your latter code, with perhaps some (usually insignificant) overhead from the enumerators.

Likewise, if you use a foreach loop:

foreach (var t in things)
    DoSomething(t);

It is similar in performance to:

foreach (var t in mythings)
    if (t.IsSomeValue && t.IsSomeOtherValue)
        DoSomething(t);

Some of the performance advantages of the laziness approach for enumerables (as opposed to calculating all the results and storing them in a list) are that it uses very little memory (since only one result is stored at a time) and that there's no significant up-front cost.

If the enumerable is only partially enumerated, this is especially important. Consider this code:

things.First();

The way LINQ is implemented, mythings will only be enumerated up to the first element that matches your where conditions. If that element is early on in the list, this can be a huge performance boost (e.g. O(1) instead of O(n)).


答:
The following code :

```<code>var things = mythings
    .Where(x => x.IsSomeValue)
    .Where(y => y.IsSomeOtherValue);
</code>```

Is equivalent to nothing, because of the lazy evaluation, nothing will happen.

```<code>var things = mythings
    .Where(x => x.IsSomeValue)
    .Where(y => y.IsSomeOtherValue)
    .ToList();
</code>```

Is different, because the evaluation will be launch.

Each item of mythings will be given to the first Where. If it passes, it will be given to the second Where. If it passes, it will be part of the output.

So this looks like more like this :

```<code>var results = new List<Thing>();
foreach(var t in mythings)
{
    if(t.IsSomeValue)
    {
        if(t.IsSomeOtherValue)
        {
            results.Add(t);
        }
    }
}
</code>```

Title: Is linq more efficient than it appears on the surface?

Body:
If I write something like this:

```<code>var things = mythings
    .Where(x => x.IsSomeValue)
    .Where(y => y.IsSomeOtherValue)
</code>```

Is this the same as:

```<code>var results1 = new List<Thing>();
foreach(var t in mythings)
    if(t.IsSomeValue)
        results1.Add(t);

var results2 = new List<Thing>();
foreach(var t in results1)
    if(t.IsSomeOtherValue)
        results2.Add(t);
</code>```

Or is there some magic under the covers that works more like this:

```<code>var results = new List<Thing>();
foreach(var t in mythings)
    if(t.IsSomeValue && t.IsSomeOtherValue)
        results.Add(t);
</code>```

Or is it something completely different altogether?

Body:
The following code :

var things = mythings
    .Where(x => x.IsSomeValue)
    .Where(y => y.IsSomeOtherValue);

Is equivalent to nothing, because of the lazy evaluation, nothing will happen.

var things = mythings
    .Where(x => x.IsSomeValue)
    .Where(y => y.IsSomeOtherValue)
    .ToList();

Is different, because the evaluation will be launch.

Each item of mythings will be given to the first Where. If it passes, it will be given to the second Where. If it passes, it will be part of the output.

So this looks like more like this :

var results = new List<Thing>();
foreach(var t in mythings)
{
    if(t.IsSomeValue)
    {
        if(t.IsSomeOtherValue)
        {
            results.Add(t);
        }
    }
}


答:
No it is not the same. In your example things is an IEnumerable, which at this point is still only an iterator, not an actual array or list. Moreover since things is not used, the loop is never even evaluated. The type IEnumerable allows to iterate through elements yield-ed by Linq instructions and process them further with more instructions, which means in the end you really have only one loop.

But as soon as you add an instruction like .ToArray() or .ToList(), you're ordering the creation of an actual data structure, thus putting bounds to your chain.

See this related SO question: https://stackoverflow.com/questions/2789389/how-do-i-implement-ienumerable


问:
Trying to sort the coefficients of the polynomial (z-a)(z-b)(z-c)...(z-n) into a vector
So I have a factored polynomial of the form (z-a)(z-b)(z-c)...(z-n) for n an even positive integer.  Thus the coefficient of z^k for 0 <= k < n will be the sum of all distinct n-k element products taken from the set {a,b,...,n} multiplied by (-1)^k, I hope that makes sense, please ask if you need more clarification.

I'm trying to put these coefficients into a row vector with the first column containing the constant coefficient (which would be abc...n) and the last column containing the coefficient for z^n (which would be 1).

I imagine there is a way to brute force this with a ton of nested loops, but I'm hoping there is a more efficient way.  This is being done in Matlab (which I'm not that familiar with) and I know Matlab has a ton of algorithms and functions, so maybe its got something I can use.  Can anyone think of a way to do this?

Example: (z-1)(z-2)(z-3) = z^3 - (1 + 2 + 3)z^2 + (1*2 + 1*3 + 2*3)z - 1*2*3 = z^3 - 6z^2 + 11z - 6.  Note that this example is n=3 odd, but n=4 would have taken too long to do by hand.

Edit: Let me know if you think this would be better posted at TCS or Math Stack Exchange.

答:
Have a look at the matlab routine poly.

```<code>>> poly([1,2,3])
ans =

     1    -6    11    -6
</code>```

Or, to be more precise,

```<code>n = length(input);
c = [1 zeros(1,n)];
for j = 1:n
    c(2:(j+1)) = c(2:(j+1)) - input(j).*c(1:j);
end
</code>```

Body:
Have a look at the matlab routine poly.

>> poly([1,2,3])
ans =

     1    -6    11    -6

Or, to be more precise,

n = length(input);
c = [1 zeros(1,n)];
for j = 1:n
    c(2:(j+1)) = c(2:(j+1)) - input(j).*c(1:j);
end


答:
Deferred execution aside (which the other answers already explain, I'll just point out another detail), it's more like in your second example.

Let's just imagine you call ToList on things.

The implementation of Enumerable.Where returns a Enumerable.WhereListIterator. When you call Where on that WhereListIterator (a.k.a. chaining Where-calls), you no longer call Enumerable.Where, but Enumerable.WhereListIterator.Where, which actually combines the predicates (using Enumerable.CombinePredicates).

So it's more like if(t.IsSomeValue && t.IsSomeOtherValue).


问:
Can I rightfully claim this as my own project if I recieved help online?
Basically I'm new to network programming in Python, so I went on a tutorial online to find out about it. Using what was taught in the tutorial (creating a socket, connecting to ports, etc), I modified the code so that I made a program where two computers can send messages to one another.

If I were to apply for a job and show this to my interviewers, would the code for it technically be mine? It is fair to say that I didn't modify the code by that much; However, what if for example I modified it into something like a tic-tac-toe game, where two users play each other from different PCs, would the code then be mine? I just don't want to look like a plagiarizer hence why I ask.

答:
No.

But you can claim that you modified the code so that you made a program where two computers can send messages to one another. Or you can claim that you modified it into something like a tic-tac-toe game, where two users play each other from different PC's.

Just truthfully represent the amount of work that you put into it.  You can't claim ownership of some project on the Internet if others did part of the work.