问:
My father wants to learn PHP-MySQL to port his application. What I should do to help?
My father is a doctor/physician. About 15 years ago he started writing an application to handle his patient's medical records in his clinic at home. The app has the ability to input patient's medical records (obviously), search patients by some criteria, manage medicine stocks, output receipt to printer, and some more CRUDs.

He wrote it in dBase III+. A few years later he migrated to FoxPro 2.6 for DOS and finally in a few more years he rewrote his app in Visual FoxPro 9. And now (actually two years ago) he wants to rewrite it in PHP, but he doesn't know how.

The Visual FoxPro version of this app is still running and has no serious problem except sometimes it performs slowly. Usually there are 1-5 concurrent users. The binary and database files are shared via windows share. He did all the coding as a hobby and for free (it is for his own clinic after all). He also use this app in two other offices he managed.

Some reasons of why he wants to rewrite in PHP-MySQL:

He wants to learn

Easier to deploy (?)

Easier client setup, need only a browser

What should I do to help my father? How should he start?

I explored some options:

I let my father learn PHP and MySQL (and HTML (and JavaScript?)) from scratch.

I create/bundle framework. I'm thinking on bundling CodeIgniter and a web UI framework (any suggestion?) especially to reduce effort on writing presentation codes.

What do you think?

tl;dr

My father (a doctor) wants to rewrite his Visual FoxPro app in PHP-MySQL. He knows very little of PHP and MySQL but he wants to learn. What should I do to help? How should he start?

Some facts:

My father is 50 years old.

His first encounter with a PC is in early 1980s. It was IBM PC with Intel 8088.

He knows BASIC.

He taught me how to use DOS and how to program with BASIC.

The other language he knows fairly well is dBase/FoxPro.

I got my bachelor CS degree last year.

I know the internals of my father's app because sometime he wants me to help him writing his app.

Update

After reading early responses, there seem to be better alternatives to PHP for this case. I'm open for other language/technology suggestions.

答: If you father is willing to spend the money, Visual Studio Lightswitch might be an option to consider. You can program in C# or VB.NET, develop 2 or 3-tier Desktop and Silverlight apps and I think the version coming out with VS 2012 is supposed to support HTML 5 clients.</p>


问:
Should an image be able to resize itself in OOP?
I'm writing an app that will have an Image entity, and I'm already having trouble deciding whose responsibility each task should be.

First I have the Image class. It has a path, width, and other attributes.

Then I created an ImageRepository class, for retrieving images with a single and tested method, eg: findAllImagesWithoutThumbnail().

But now I also need to be able to createThumbnail(). Who should deal with that? I was thinking about having an ImageManager class, which would be an app-specific class (there would also be a third party image manipulation reusable component of choice, I'm not reinventing the wheel).

Or maybe it would be 0K to let the Image resize itself? Or let the ImageRepository and ImageManager be the same class?

What do you think?

答:
You have identified a single functionality you want to implement, so why shouldn't it be separate from everything you have identified so far? That is what the Single Responsibility Principle would suggest is the solution.

Create an IImageResizer interface that allows you to pass in an image and a target size, and which returns a new image. Then create an implementation of that interface. There are actually tons of ways to resize images, so you could even end up with more than one!

ContentLicense: CC BY-SA 3.0


问:
Using XML as data storage
I was thinking about the XML format and the following quote:

“XML is not a database. It was never meant to be a database. It is never going to be a database. Relational databases are proven technology with more than 20 years of implementation experience. They are solid, stable, useful products. They are not going away. XML is a very useful technology for moving data between different databases or between databases and other programs. However, it is not itself a database. Don't use it like one.“ -Effective XML: 50 Specific Ways to Improve Your XML by Elliotte Rusty Harold (page 230, Part 4, Item 41, 2nd paragraph)

This seems to really stress that XML should not be used for data storage and should only be used for program to program interoperability.

Personally, I disagree and .NET's app.config file that's used to store a program's settings is an example of data storage in an XML file. However for databases rather than configurations etc XML should not be used.

To develop my point, I will use two examples:

A) Data about customers with fields that are all on one level i.e. there are a number of fields all relating to one customer with no children

B) Data about configuration of an application where nested fields and properties make a lot of sense

So my question is, Is this still a valid statement and is it now acceptable to store data using XML?

EDIT: I've sent an email to the author of that quote to ask for his input/extra context.

答:
XML never meant to be a database or replace it.

XML is mainly defined for Web documents that allows for the creation of customized tags for individual information fields. However, you would never achieve relational centralized data management with it.

Title: Using XML as data storage


问:
Specifying Author in Source Code in a Commercial Product
Usually there is an <code>@author</code> tag in API documentation (JavaDoc, PHPDoc etc). Is it acceptable to use this tag on every function you make in a commercial product? </p>

答:
The author tag may serve two purposes:

Claim code ownership

Provide a point-of-contact for future code maintenance needs

Purpose 1 may be a legitimate use for some projects, but its use must be governed and enforced by the project team. For commercial closed-source project, it is likely that this usage could be forbidden.

Purpose 2 may serve a legitimate, yet transient (temporary) need to help establish multiple points-of-contact in distributed teams that don't normally communicate. In other words, teams that had broken or non-existent communication channels, and missing some standard software development practices. Putting that information in a project wiki, or ensuring that source control commit history is accurate and accessible to everyone (developers as well as API users), will be a better alternative.

Consult with project lead if you encounter this tag in existing code, to see whether it should be kept or removed.

If you see this tag that refers to a person not in your company, it may be a sign of improper code appropriation (e.g. stealing code from other sources without attribution and/or licensing), which is a different and much bigger issue.


答:
Heh, I never thought that by using the @author tag I was claiming ownership of the code, in my mind it was more of a "if this breaks, blame me" comment. I've long given up on writing such comments though, version control is my preferred way of finding who to blame when stuff break.

If you must show code ownership in the legal sense, then have your @author tag in the page/class level DocBlock, and don't forget to point to the code's license with the @license tag.

Title: Specifying Author in Source Code in a Commercial Product

Body: Usually there is an <code>@author</code> tag in API documentation (JavaDoc, PHPDoc etc). Is it acceptable to use this tag on every function you make in a commercial product? </p>


问:
Why is it you never get as much done as you'd planned?
I always start the day thinking "I'll easily get this done by the end of the day" and set what looks like a realistic target.

So why do I never hit it? The task always ends up taking 3x longer due to unforeseen bugs, last minute changes etc.

Is it just me?  I don't seem to be getting any better predicting what can be done in a day.

答:
cuz you simply ignored the fact that unforeseen bugs may occur.

Do some statistics on the average time you spent on the bugs, and take those time into account when you make your plan.

ContentLicense: CC BY-SA 2.5


问:
Must all new features go through betatest?
Obviously, small usability fixes and bugfixes go directly into the stable product. What about small new features? Can you afford to just release them after internal testing, or do they have to be betatested by customers first?

Situation: This is a young commercial project, produced by a one-person company. It has an existing userbase and is at it's second major version. Previous betatests have produced some results, however most feedback came from the stable product and not from beta versions.

答:
Ideally, it should go as a trial feature.

If that feature is not requested by clients and did NOT have a UAT, it would be better to keep it as a Trial or Beta, without forcing clients to install it.


答:
I'd advise to do some product research and see if there is an "off the shelf" system that will do a better job for a smaller outlay of time and money.

The fundamental problem here is that those medical records are business critical in a couple of respects:

If they get lost or corrupted, it is going to affect your Dad's ability to run his medical practice.

If there is a security or privacy breach, there is a possibility of your Dad running foul of the relevant law on medical record keeping (IANAL), and/or being sued by patients.

IMO, it would be better to use a system built by some company with experience in addressing those concerns, than "winging it" with a home-made system.

Title: My father wants to learn PHP-MySQL to port his application. What I should do to help?

Body:
My father is a doctor/physician. About 15 years ago he started writing an application to handle his patient's medical records in his clinic at home. The app has the ability to input patient's medical records (obviously), search patients by some criteria, manage medicine stocks, output receipt to printer, and some more CRUDs.

He wrote it in dBase III+. A few years later he migrated to FoxPro 2.6 for DOS and finally in a few more years he rewrote his app in Visual FoxPro 9. And now (actually two years ago) he wants to rewrite it in PHP, but he doesn't know how.

The Visual FoxPro version of this app is still running and has no serious problem except sometimes it performs slowly. Usually there are 1-5 concurrent users. The binary and database files are shared via windows share. He did all the coding as a hobby and for free (it is for his own clinic after all). He also use this app in two other offices he managed.

Some reasons of why he wants to rewrite in PHP-MySQL:

He wants to learn

Easier to deploy (?)

Easier client setup, need only a browser

What should I do to help my father? How should he start?

I explored some options:

I let my father learn PHP and MySQL (and HTML (and JavaScript?)) from scratch.

I create/bundle framework. I'm thinking on bundling CodeIgniter and a web UI framework (any suggestion?) especially to reduce effort on writing presentation codes.

What do you think?

tl;dr

My father (a doctor) wants to rewrite his Visual FoxPro app in PHP-MySQL. He knows very little of PHP and MySQL but he wants to learn. What should I do to help? How should he start?

Some facts:

My father is 50 years old.

His first encounter with a PC is in early 1980s. It was IBM PC with Intel 8088.

He knows BASIC.

He taught me how to use DOS and how to program with BASIC.

The other language he knows fairly well is dBase/FoxPro.

I got my bachelor CS degree last year.

I know the internals of my father's app because sometime he wants me to help him writing his app.

Update

After reading early responses, there seem to be better alternatives to PHP for this case. I'm open for other language/technology suggestions.


答:
XML is lousy for data storage.  First, it is very verbose.  Data stored in an XML file will take much more disk space then the same data stored in any reasonable database system.  In an XML record, the name of a particular field will be stored twice, along with the string representation of the data.  So, for example, to store a single integar in a field called "foobar", you end up with this 19 byte string:

```<code><foobar>42</foobar>
</code>```

On the other hand, a real database will store this as a single integar value, taking 4 bytes.  If your database is small, that doesn't mean much, but if you have 10,000 records, that's a problem.

Second, an XML has to be parsed from text every single time the file is read.  For the above field, a real database simply reads the binary data into memory from the offset it knows it stored the field "foobar" in.  If the file is stored as XML, it has to read the field "foobar", parse that text, determine what field it is, then parse the string "42" and convert it into the binary 42.

Thus the performance penalties for using XML are huge.  The benefits of XML are that it is somewhat human readable, and that it allows for easy transfer of data between completely separate systems.  Neither of those advantages applies for a local database.

The one exception is configuration files, which are generally small, and generally need to be editable by humans.

An XML database absolutely will be larger and slower than any reasonable SQL system.  Unless you can find a counterbalancing advantage in human readability or interoperability, there's just no point in using it for data storage.

Title: Using XML as data storage

Body:
I was thinking about the XML format and the following quote:

“XML is not a database. It was never meant to be a database. It is never going to be a database. Relational databases are proven technology with more than 20 years of implementation experience. They are solid, stable, useful products. They are not going away. XML is a very useful technology for moving data between different databases or between databases and other programs. However, it is not itself a database. Don't use it like one.“ -Effective XML: 50 Specific Ways to Improve Your XML by Elliotte Rusty Harold (page 230, Part 4, Item 41, 2nd paragraph)

This seems to really stress that XML should not be used for data storage and should only be used for program to program interoperability.

Personally, I disagree and .NET's app.config file that's used to store a program's settings is an example of data storage in an XML file. However for databases rather than configurations etc XML should not be used.

To develop my point, I will use two examples:

A) Data about customers with fields that are all on one level i.e. there are a number of fields all relating to one customer with no children

B) Data about configuration of an application where nested fields and properties make a lot of sense

So my question is, Is this still a valid statement and is it now acceptable to store data using XML?

EDIT: I've sent an email to the author of that quote to ask for his input/extra context.

Body:
XML is lousy for data storage.  First, it is very verbose.  Data stored in an XML file will take much more disk space then the same data stored in any reasonable database system.  In an XML record, the name of a particular field will be stored twice, along with the string representation of the data.  So, for example, to store a single integar in a field called "foobar", you end up with this 19 byte string:

<foobar>42</foobar>

On the other hand, a real database will store this as a single integar value, taking 4 bytes.  If your database is small, that doesn't mean much, but if you have 10,000 records, that's a problem.

Second, an XML has to be parsed from text every single time the file is read.  For the above field, a real database simply reads the binary data into memory from the offset it knows it stored the field "foobar" in.  If the file is stored as XML, it has to read the field "foobar", parse that text, determine what field it is, then parse the string "42" and convert it into the binary 42.

Thus the performance penalties for using XML are huge.  The benefits of XML are that it is somewhat human readable, and that it allows for easy transfer of data between completely separate systems.  Neither of those advantages applies for a local database.

The one exception is configuration files, which are generally small, and generally need to be editable by humans.

An XML database absolutely will be larger and slower than any reasonable SQL system.  Unless you can find a counterbalancing advantage in human readability or interoperability, there's just no point in using it for data storage.


答:
my question is, Is this still a valid statement and is it now acceptable to store data using XML?

I see your point in you example about .NET configuration files. However, any other file format could have been used. In fact, in the old days, such settings used to be stored in regular text files called INI files.

I see that the statement you have presented in gray, is valid and correct if you define a database as a software system.

The definition of XML in XML-Definition
states that " (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable."

This definition focuses on readability and language rather than on mechanisms to manage the data.

Compared to an RDBMS, XML does not provide means to randomly insert and delete rows in an XML file. For example, if you have 1000000 rows, and you wanted to delete rows at random even in a single user environment XML based file would not be a good choice for a database. Also, XML does not provide any native mechanisms for locking data. In fact, since XML is not a software, all ACID (atomicity, consistency, isolation, durability)  properties that guarantee that database transactions are processed reliably in a shared environment are left to the developer to build (with the exception of Durability).
XML does not have a robust specification to handle data integrity across XML files, let alone different servers (e.g. customer xml file and orders xml file - No FKs to enforce integrity).

The above is not an enumeration of what XML lacks, instead, it could server as a quick justification of the statement that XML is not a database software.

Title: Using XML as data storage


答:
Short answer:
It depends.

Long answer:
From my point of view this strongly depends on the amount of data you want to store. E.g. if you have a couple of objects in your application during runtime and you want to store them after running the tool a XML file is perfectly fine. However, if your webshop has 5000 custumers and even more orders a database would be a more appropriate data storage.

Additionally I think storing settings in a database and not in a file like app.config is in most cases not very useful, but I don't think this example proves the quote wrong.

Title: Using XML as data storage


答:
I assume those facts about method, that resizes images:

It must return new copy of image. You cannot modify the image itself, because it would break other code that has reference to this image.

It doesn't need access to the internal data of Image class. Image classes usually need to offer public access to those data (or copy of).

Image resizing is complex and requires many different parameters. Maybe even extensibility points for different resizing algorithms. Passing everything would result in big method signature.

Based on those facts, I would say that there is no reason for Image resizing method be part of Image class itself. Implementing it as static helper method of class would be best.

Title: Should an image be able to resize itself in OOP?

Body:
I'm writing an app that will have an Image entity, and I'm already having trouble deciding whose responsibility each task should be.

First I have the Image class. It has a path, width, and other attributes.

Then I created an ImageRepository class, for retrieving images with a single and tested method, eg: findAllImagesWithoutThumbnail().

But now I also need to be able to createThumbnail(). Who should deal with that? I was thinking about having an ImageManager class, which would be an app-specific class (there would also be a third party image manipulation reusable component of choice, I'm not reinventing the wheel).

Or maybe it would be 0K to let the Image resize itself? Or let the ImageRepository and ImageManager be the same class?

What do you think?


答:
Keep things simple as long as there are only a few requirements, and improve your design when you have to. I guess in most real-world cases there is nothing wrong to start with a design like that:

```<code>class Image
{
    public Image createThumbnail(int sizeX, int sizeY)
    {
         // ...
         // later delegate the actual resize operation to a separate component
    }
}
</code>```

Things may become different when you need to pass more parameters to createThumbnail(), and those parameters need a lifetime of their own. For example, lets assume you are going to create thumbnails for several hundred images, all with some given destination size, resize algorithm or quality. That will mean that you could move the createThumbnail to another class, for example, a manager class, or an ImageResizer class, where those parameters are passed in by the constructor and so are bound to the lifetime of the ImageResizer object.

Actually, I would start with the first approach and refactor later when I really need it.

Body:
Keep things simple as long as there are only a few requirements, and improve your design when you have to. I guess in most real-world cases there is nothing wrong to start with a design like that:

class Image
{
    public Image createThumbnail(int sizeX, int sizeY)
    {
         // ...
         // later delegate the actual resize operation to a separate component
    }
}

Things may become different when you need to pass more parameters to createThumbnail(), and those parameters need a lifetime of their own. For example, lets assume you are going to create thumbnails for several hundred images, all with some given destination size, resize algorithm or quality. That will mean that you could move the createThumbnail to another class, for example, a manager class, or an ImageResizer class, where those parameters are passed in by the constructor and so are bound to the lifetime of the ImageResizer object.

Actually, I would start with the first approach and refactor later when I really need it.


问:
How best to keep bumbling, non-technical managers at bay and still deliver good work?
This question may be considered subjective (I got a warning) and be closed, but I will risk it, as I need some good advice/experience on this.

I read the following at the 'About' page of Fog Creek Software, the company that Joel Spolsky founded and is CEO of:

Back in the year 2000, the founders of Fog Creek, Joel Spolsky and
  Michael Pryor, were having trouble finding a place to work where
  programmers had decent working conditions and got an opportunity to do
  great work, without bumbling, non-technical managers getting in the
  way. Every high tech company claimed they wanted great programmers,
  but they wouldn’t put their money where their mouth was.

It started with the physical environment (with dozens of cubicles
  jammed into a noisy, dark room, where the salespeople shouting on the
  phone make it impossible for developers to concentrate). But it went
  much deeper than that. Managers, terrified of change, treated any new
  idea as a bizarre virus to be quarantined. Napoleon-complex junior
  managers insisted that things be done exactly their way or you’re
  fired. Corporate Furniture Police writhed in agony when anyone taped
  up a movie poster in their cubicle. Disorganization was so rampant
  that even if the ideas were good, it would have been impossible to
  make a product out of them. Inexperienced managers practiced
  hit-and-run management, issuing stern orders on exactly how to do
  things without sticking around to see the farcical results of their
  fiats.

And worst of all, the MBA-types in charge thought that coding was a
  support function, basically a fancy form of typing.

A blunt truth about most of today's big software companies! Unfortunately not every developer is as gutsy (or lucky, may I say?) as Joel Spolsky! So my question is:

How best to work with such managers, keep them at bay and still deliver great work?

答:
Option 1 : Become manager yourself and show everyone how to do things right. You will probably find out it is not as easy as many programmers think.

Option 2 : Leave and find better place to work. I believe there are many big and small companies that at least know of this problem and try to solve it. With varying degrees of success.


答:
While developers are perceived to be ignorant of the business problems, less technical managers will look down on developers. Developers need to learn the business cases and start driving or suggesting improvements in business terms. Once developers and managers are speaking the same language, things get easier.

This is as much about an attitude change. Yes, there will always be ahem stubborn individuals in management. However, creating an "us and them" attitude reinforces this from both sides.

Title: How best to keep bumbling, non-technical managers at bay and still deliver good work?

Body:
This question may be considered subjective (I got a warning) and be closed, but I will risk it, as I need some good advice/experience on this.

I read the following at the 'About' page of Fog Creek Software, the company that Joel Spolsky founded and is CEO of:

Back in the year 2000, the founders of Fog Creek, Joel Spolsky and
  Michael Pryor, were having trouble finding a place to work where
  programmers had decent working conditions and got an opportunity to do
  great work, without bumbling, non-technical managers getting in the
  way. Every high tech company claimed they wanted great programmers,
  but they wouldn’t put their money where their mouth was.

It started with the physical environment (with dozens of cubicles
  jammed into a noisy, dark room, where the salespeople shouting on the
  phone make it impossible for developers to concentrate). But it went
  much deeper than that. Managers, terrified of change, treated any new
  idea as a bizarre virus to be quarantined. Napoleon-complex junior
  managers insisted that things be done exactly their way or you’re
  fired. Corporate Furniture Police writhed in agony when anyone taped
  up a movie poster in their cubicle. Disorganization was so rampant
  that even if the ideas were good, it would have been impossible to
  make a product out of them. Inexperienced managers practiced
  hit-and-run management, issuing stern orders on exactly how to do
  things without sticking around to see the farcical results of their
  fiats.

And worst of all, the MBA-types in charge thought that coding was a
  support function, basically a fancy form of typing.

A blunt truth about most of today's big software companies! Unfortunately not every developer is as gutsy (or lucky, may I say?) as Joel Spolsky! So my question is:

How best to work with such managers, keep them at bay and still deliver great work?


答:
An Image Processing class might be appropriate (or Image Manager, as you called it).  Pass your Image to a CreateThumbnail method of the Image Processor, for example, to retrieve a thumbnail image.

One of the reasons I'd suggest this route is that you say you're using a 3rd party image processing library.  Taking the resizing functionality out of the Image class itself might make it easier for you to isolate any platform specific or 3rd party code.  So if you can use your base Image class across all platforms/apps, you then dont have to pollute it with platform or library specific code.  That can all be located in the Image Processor.


问:
Linux OpenGL programming, should I use GLX or any other?
I'm new to OpenGL and found that there are a lot of libraries to do that in C,
and I also found that glx is most friendly with Linux X Server, I just want to do basic stuff, and I cannot find any tutorials for GLX.

Is GLX a bad thing? I just want to do some small graphical things without installing many libraries and getting confused. Can anyone suggest me something which has tutorials and simple to compile?

I found a link with an example with GLX and it worked perfect with no errors: anyone please suggest where I can find nice documentation or any better libraries.

答:
GLX library is written to communicate OpenGL application with the X server. It probably doesn't do anything more than that, but it's enough for you. When you create and set up your window and GL context with GLX, you start using OpenGL like everywhere else. In other hand do you really want to set up everything yourself using so low-level libraries only to draw a 3D sphere? IMO it overkill. Won't it be better for you to use a wrapper framework, like i.e. GLFW? It'll do for you everything you'll want to without need of writing a lot of redundant C-code.

And if you are using Linux, installing additional libraries (or any other package) sure won't be a problem. Every distro is using package manager, which makes installing almost anything very easy.


问:
High-Level Application Architecture Question
So I'm really wanting to improve how I architect the software I code. I want to focus on maintainability and clean code. As you might guess, I've been reading a lot of resources on this topic and all it's doing is making it harder for me to settle on an architecture because I can never tell if my design is the one that the more experienced programmer would've chosen.

So I have these requirements:

I should connect to one vendor and download form submissions from their API. We'll call them the CompanyA.

I should then map those submissions to a schema fit for submitting to another vendor for integration with the email service provider. We'll call them the CompanyB.

I should then submit those responses to the ESP (CompanyB) and then instruct the ESP to send that submitter an email.

So basically, I'm copying data from one web service to another and then performing an action at the latter web service.

I've identified a couple high-level services:

The service that downloads data from CompanyA. I called this the CompanyAIntegrator.

The service that submits the data to CompanyB. I called this CompanyBIntegrator.

So my questions are these:

Is this a good design? I've tried to separate the concerns and am planning to use the facade pattern to make the integrators interchangeable if the vendors change in the future.

Are my naming conventions accurate and meaningful to you (who knows nothing specific of the project)?

Now that I have these services, where should I do the work of taking output from the CompanyAIntegrator and getting it in the format for input to the CompanyBIntegrator? Is this OK to be done in main()?

Do you have any general pointers on how you'd code something like this? I imagine this scenario is common to us engineers---especially those working in agencies.

Thanks for any help you can give. Learning how to architect well is really mind-cluttering.

答:
Keep it simple. Write well-modularized classes that separate concerns. Your class names are fine, and you have the right idea that the two “integrators” should have no knowledge of each other and a third class should make calls into them to do the work. You won’t do it in main() if it’s a web app, main isn’t even exposed.

I wouldn’t bother with the facades. Even if the vendors are replaced, the new vendors won’t have API’s, schemas and email providers that necessarily provide you with a clean mapping to your facade or interface. So you'd be making your client code write to an abstract layer, which isn’t needed now (premature optimization), and which you likely will have to rewrite in the future in any case.


答:
imho the names are not good. What do CompanyBIntegrator tell you? that it's an integration. But does it tell you what the integration does? No.

IYourEntityDownloader or something like that is better. It tells you what it does.

As for the process, I would do something like this (soc):

Have a job that download the information and store it in a data store (db, flat file, memory etc)

Have a job that processes the information according to your business rules and then store the result in another data store

Have a job that takes the processed information and upload it to company b.

By having those three steps you can expend each separate step as much as you like without affecting the other parts. You could even use three different servers (or hundreds for that matter) .

You can also start downloading information from one source but upload to five destinations. The other parts would be unaware of that too since they have clear responsibilities.

Title: High-Level Application Architecture Question

Body:
So I'm really wanting to improve how I architect the software I code. I want to focus on maintainability and clean code. As you might guess, I've been reading a lot of resources on this topic and all it's doing is making it harder for me to settle on an architecture because I can never tell if my design is the one that the more experienced programmer would've chosen.

So I have these requirements:

I should connect to one vendor and download form submissions from their API. We'll call them the CompanyA.

I should then map those submissions to a schema fit for submitting to another vendor for integration with the email service provider. We'll call them the CompanyB.

I should then submit those responses to the ESP (CompanyB) and then instruct the ESP to send that submitter an email.

So basically, I'm copying data from one web service to another and then performing an action at the latter web service.

I've identified a couple high-level services:

The service that downloads data from CompanyA. I called this the CompanyAIntegrator.

The service that submits the data to CompanyB. I called this CompanyBIntegrator.

So my questions are these:

Is this a good design? I've tried to separate the concerns and am planning to use the facade pattern to make the integrators interchangeable if the vendors change in the future.

Are my naming conventions accurate and meaningful to you (who knows nothing specific of the project)?

Now that I have these services, where should I do the work of taking output from the CompanyAIntegrator and getting it in the format for input to the CompanyBIntegrator? Is this OK to be done in main()?

Do you have any general pointers on how you'd code something like this? I imagine this scenario is common to us engineers---especially those working in agencies.

Thanks for any help you can give. Learning how to architect well is really mind-cluttering.


答:
Your job is to deliver great work. Managing is a support function, its purpose is to enable you to deliver great work - act as a buffer between you and the clients & stakeholders & politics & sales etc, remove obstacles, abstract away everyday crap that prevents you from achieving your best.

Think of the memory manager. It's not the boss that commands you and your programs, rather, it frees you from considering everything else that's going on in the computer, letting you to concentrate on what's essential for your program. That's what Joel is writing about, that's how managers ideally should work.

Not all managers are perfect, but nor are you. Nothing is. Unless things are totally crazy, then just suck it up and do the best you can, ignore what annoys you, and concentrate on your work. If you deliver great work, the managers will eventually respect and trust you more and let you work more in your way, once you've shown that you can deliver great work.

It's okay to work in a 70 % perfect organization. If your situation is really bad, then switch your employer. But don't give up too soon; the process of earning trust - convincing your managers and the organization of your abilities - can take years.


答:
XML is an excellent choice for configuration settings.  Not only are XML files easy to parse/highlight in an IDE, they're very easy for non-programmers to edit.  I find them incredibly useful in web development scenarios where maintenance tasks are being performed by designers and content managers.

XML should typically not be used as a primary data source for any non-trivial applications.  The serialization/deserialization overhead alone begs for a different solution.

Title: Using XML as data storage


问:
What is the meaning of 'high cohesion'?
I am a student who recently joined a software development company as an intern.  Back at the university, one of my professors used to say that we have to strive to achieve "Low coupling and high cohesion".

I understand the meaning of low coupling. It means to keep the code of separate components separately, so that a change in one place does not break the code in another.

But what is meant by high cohesion. If it means integrating the various pieces of the same component well with each other, I dont understand how that becomes advantageous.

What is meant by high cohesion? Can an example be explained to understand its benefits?

答:
One way of looking at cohesion in terms of OO is if the methods in the class are using any of the private attributes. Using metrics such as LCOM4 (Lack of Cohesive Methods), as pointed out by gnat in this answer here, you can identify classes that could be refactored. The reason you want to refactor methods or classes to be more cohesive is that it makes the code design simpler for others to use it. Trust me; most tech leads and maintenance programmers will love you when you fix these issues.

You can use tools in your build process such as Sonar to identify low cohesion in the code base. There are a couple of very common cases that I can think of where methods are low in "cohesiveness":

Case 1: Method is not related to the class at all

Consider the following example:

public class Food {
   private int _foodValue = 10;

   public void Eat() {
     _foodValue -= 1;
   }

   public void Replenish() {
     _foodValue += 1;
   }

   public void Discharge() {
     Console.WriteLine("Nnngghhh!");
   }
}
```

<p>One of the methods, <code>Discharge()</code>, lacks cohesion because it doesn't touch any of the class's private members. In this case there is only one private member: <code>_foodValue</code>. If it doesn't do anything with the class internals, then does it really belong there? The method could be moved to another class that could be named e.g.<code>FoodDischarger</code>.</p>

<pre class="lang-cs prettyprint-override"><code>// Non-cohesive function extracted to another class, which can
// be potentially reused in other contexts
public FoodDischarger {
  public void Discharge() {
    Console.WriteLine("Nnngghhh!");
  }
}
</code>```

In you're doing it in Javascript, since functions are first-class objects, the discharge can be a free function:

function Food() {
    this._foodValue = 10;
}
Food.prototype.eat = function() {
    this._foodValue -= 1;
};
Food.prototype.replenish = function() {
    this._foodValue += 1;
};

// This
Food.prototype.discharge = function() {
    console.log('Nnngghhh!');
};
// can easily be refactored to:
var discharge = function() {
    console.log('Nnngghhh!');
};
// making it easily reusable without creating a class
```

<h2>Case 2: Utility Class</h2>

<p>This is actually a common case that breaks cohesion. Everyone <em>loves</em> utility classes, but these usually indicate design flaws and most of the time makes the codebase trickier to maintain (because of the high dependency associated with utility classes). Consider the following classes:</p>

<pre class="lang-cs prettyprint-override"><code>public class Food {
    public int FoodValue { get; set; }
}

public static class FoodHelper {

    public static void EatFood(Food food) {
        food.FoodValue -= 1;
    }

    public static void ReplenishFood(Food food) {
        food.FoodValue += 1;
    }

}
</code>```

Here we can see that the utility class needs to access a property in the class Food. The methods in the utility class has no cohesion at all in this case because it needs outside resources to do it's work. In this case, wouldn't it be better to have the methods in the class they're working with itself (much like in the first case)?

Case 2b: Hidden objects in Utility Classes

There is another case of utility classes where there are unrealized domain objects. The first knee-jerk reaction a programmer has when programming string manipulation is to write a utility class for it. Like the one here that validates a couple of common string representations:

public static class StringUtils {

  public static bool ValidateZipCode(string zipcode) {
    // validation logic
  }

  public static bool ValidatePhoneNumber(string phoneNumber) {
    // validation logic
  }

}
```

<p>What most don't realize here is that a zip code, a phone number, or any other string repesentation can be an object itself:</p>

<pre class="lang-cs prettyprint-override"><code>public class ZipCode {
    private string _zipCode;
    public bool Validates() {
      // validation logic for _zipCode
    }
}

public class PhoneNumber {
    private string _phoneNumber;
    public bool Validates() {
      // validation logic for _phoneNumber
    }
}
</code>```

The notion that you shouldn't "handle strings" directly is detailed in this blogpost by @codemonkeyism, but is closely related to cohesion because the way programmers use strings by putting logic in utility classes.

Title: What is the meaning of 'high cohesion'?

Body:
One way of looking at cohesion in terms of OO is if the methods in the class are using any of the private attributes. Using metrics such as LCOM4 (Lack of Cohesive Methods), as pointed out by gnat in this answer here, you can identify classes that could be refactored. The reason you want to refactor methods or classes to be more cohesive is that it makes the code design simpler for others to use it. Trust me; most tech leads and maintenance programmers will love you when you fix these issues.

You can use tools in your build process such as Sonar to identify low cohesion in the code base. There are a couple of very common cases that I can think of where methods are low in "cohesiveness":

Case 1: Method is not related to the class at all

Consider the following example:

public class Food {
   private int _foodValue = 10;

   public void Eat() {
     _foodValue -= 1;
   }

   public void Replenish() {
     _foodValue += 1;
   }

   public void Discharge() {
     Console.WriteLine("Nnngghhh!");
   }
}

One of the methods, Discharge(), lacks cohesion because it doesn't touch any of the class's private members. In this case there is only one private member: _foodValue. If it doesn't do anything with the class internals, then does it really belong there? The method could be moved to another class that could be named e.g.FoodDischarger.

// Non-cohesive function extracted to another class, which can
// be potentially reused in other contexts
public FoodDischarger {
  public void Discharge() {
    Console.WriteLine("Nnngghhh!");
  }
}

In you're doing it in Javascript, since functions are first-class objects, the discharge can be a free function:

function Food() {
    this._foodValue = 10;
}
Food.prototype.eat = function() {
    this._foodValue -= 1;
};
Food.prototype.replenish = function() {
    this._foodValue += 1;
};

// This
Food.prototype.discharge = function() {
    console.log('Nnngghhh!');
};
// can easily be refactored to:
var discharge = function() {
    console.log('Nnngghhh!');
};
// making it easily reusable without creating a class

Case 2: Utility Class

This is actually a common case that breaks cohesion. Everyone loves utility classes, but these usually indicate design flaws and most of the time makes the codebase trickier to maintain (because of the high dependency associated with utility classes). Consider the following classes:

public class Food {
    public int FoodValue { get; set; }
}

public static class FoodHelper {

    public static void EatFood(Food food) {
        food.FoodValue -= 1;
    }

    public static void ReplenishFood(Food food) {
        food.FoodValue += 1;
    }

}

Here we can see that the utility class needs to access a property in the class Food. The methods in the utility class has no cohesion at all in this case because it needs outside resources to do it's work. In this case, wouldn't it be better to have the methods in the class they're working with itself (much like in the first case)?

Case 2b: Hidden objects in Utility Classes

There is another case of utility classes where there are unrealized domain objects. The first knee-jerk reaction a programmer has when programming string manipulation is to write a utility class for it. Like the one here that validates a couple of common string representations:

public static class StringUtils {

  public static bool ValidateZipCode(string zipcode) {
    // validation logic
  }

  public static bool ValidatePhoneNumber(string phoneNumber) {
    // validation logic
  }

}

What most don't realize here is that a zip code, a phone number, or any other string repesentation can be an object itself:

public class ZipCode {
    private string _zipCode;
    public bool Validates() {
      // validation logic for _zipCode
    }
}

public class PhoneNumber {
    private string _phoneNumber;
    public bool Validates() {
      // validation logic for _phoneNumber
    }
}

The notion that you shouldn't "handle strings" directly is detailed in this blogpost by @codemonkeyism, but is closely related to cohesion because the way programmers use strings by putting logic in utility classes.


问:
What is the use of Spring's init-method and destroy-method?
While learning Spring framework, I found that Spring framework provides init-method and destroy-methods which can be used to initialize some properties or to do housekeeping stuff.

We can do all those things in the bean's constructor so why do Spring provides these things and in the real world what is the actual use of these two things?

答: For setter injection of XML configured beans, the init-method gives you the opportunity to check the state of your object before any methods get called. Remember there is no compile-time check that an argument is passed to initialize each field of the object. So even though a setter may be defined in the java class, the bean definition in the XML could be missing a property tag.</p>


问:
Would I benefit changing from PHP to Node.js (in context)
The situation: We are about to roll out what is essentially a logging service. As we are rather PHP heavy, the current implementation use it.

We will have about 200 computers (most on the same network) that will each send, via HTTP POST, around 5000 requests/day. With each request containing about 300 bytes of data.

The receiving end is hosted at Amazon and is a very simple PHP form with some simple validation that puts everything in a database.

Now, I've recently been introduced to Node.js and I'm curious as to if it would be a good fit for the backend here.

Granted I could easily build something to test this. But since I haven't fully grasped the async-methology I would really like someone with experience to explain it to me.

答:
If you and your team have good experience with PHP and it's simple enough to implement, I would stick with that. If the amount of traffic goes up and concurrency is an issue, then it might be worth getting to grips with node (plus it's always fun to learn a new language!!).

The other benefit of node is; it's fast.

But again in this scenario I can't imagine that some well written PHP would have any difficulties handling the load.


答:
This seems to really stress that XML should not be used for data
  storage and should only be used for program to program
  interoperability.

Your premise is flawed.

The paragraph you quote is actually saying that XML is not a replacement for a database, not that it shouldn't be used for data storage.

It is clear that a settings file is not the same thing as a database, and so different technologies can (and should?) be used.

Correct me if I am wrong, but you seem to have more experience with mark-up languages than databases. If you got a bit of experience with databases you'd realise which domains the two different techologies are suited for.

Title: Using XML as data storage


答:
I used node.js for my BSc thesis and it was a very nice experience. In addition to that, it was used together with a php application so I could compare both technologies.

If you have enough time on your hands(not too much if you are familiar with javascript), then you might as well try it out. That way, you will know whether to implement it in the upcoming project which may require more concurrency.

Title: Would I benefit changing from PHP to Node.js (in context)

Body:
The situation: We are about to roll out what is essentially a logging service. As we are rather PHP heavy, the current implementation use it.

We will have about 200 computers (most on the same network) that will each send, via HTTP POST, around 5000 requests/day. With each request containing about 300 bytes of data.

The receiving end is hosted at Amazon and is a very simple PHP form with some simple validation that puts everything in a database.

Now, I've recently been introduced to Node.js and I'm curious as to if it would be a good fit for the backend here.

Granted I could easily build something to test this. But since I haven't fully grasped the async-methology I would really like someone with experience to explain it to me.


答:
Don't forget about meetings, people interrupting you, etc.  Unforseen bugs are difficult to predict, but over time you should be able to get an idea of how many bugs you uncover within a certain time frame.  When estimating how long something will take, you have to consider the context.  I.e. "Assuming I don't get interrupted or uncover bugs I should be able to do something in X amount of time"

As a little exercise for yourself, consider doing the following:

At the beginning of the day, write down what your goal is and the time estimate for it.

At every interruption (meeting, coworker talking, etc.), jot down the approximate length of time

Every time you find a new bug, jot it down as an unplanned task along with approximately how long it took to develop it.

You'll find some patterns start to emerge, and can plan accordingly for those.  Any time you tell your manager an estimated time of completion, just caveat it with the assumption in the first paragraph.  You might be surprised how accurate your estimate was when you remove the time spent on interruptions and bugs.

When you are working to a bug list or feature list, you are probably already doing the first and third bullet point.  That little exercise will tell you where all your time is going, and you might be surprised at the answer.

Title: Why is it you never get as much done as you'd planned?

Body:
I always start the day thinking "I'll easily get this done by the end of the day" and set what looks like a realistic target.

So why do I never hit it? The task always ends up taking 3x longer due to unforeseen bugs, last minute changes etc.

Is it just me?  I don't seem to be getting any better predicting what can be done in a day.


问:
How do I make code bound to an ORM testable?
In Test Driven Development, how do I make code bound to an ORM testable?

I am using a Micro-ORM (PetaPoco) and I have several methods that interact with the database like:

AddCustomer

UpdateRecord

etc.

I want to know how to write a test for these methods. I searched YouTube for videos on writing a test for DAL, but I didn't find any.

I want to know which method or class is testable and how to write a test before writing the code itself.

答:
Look into Mock Objects and Dependency Injection.

Mock objects are a useful way to write unit tests for objects that act as mediators. Instead of calling the real domain objects, the tested object calls a mock domain object that merely asserts that the correct methods were called, with the expected parameters, in the correct order.

Dependency injection allows you to test a class in isolation, for example image a class with 5 private members, these objects are initilised in the constructor. Now unit testing of this class and its methods will also be running code concerned with other objects, this defeats the purpose of unit testing. Dependency injection allows the caller to pass in the 5 initialized objects and the constructor simply assigns them to the private members for example. This means I can pass in MockDB for example when unit testing, but for production code, pass in the real concrete DB object.


答:
This quote is not about using XML as a storage format in general (for which it is fine, depending on the requirements), but for database-type storage.

When people talk about databases, they usually mean storage systems that store huge quantities of data, often in the gigabyte or terabyte range. A database is potentially much larger than the amount of available RAM on the server that stores it. Since nobody ever needs all the data in a database at once, databases should be optimized for fast retrieval of selective subsets of their data: this is what the SELECT statement is for, and relational databases as well as NoSQL solutions optimize their internal storage format for fast retrieval of such subsets.

XML, however, doesn't really fit these requirements. Due to its nested tag structure, it is impossible to determine where in the file a certain value is stored (in terms of a byte offset into a file) without walking the entire document tree, at least up to the match. A relational database has indexes, and looking up a value in an index, even with a primitive binary-search implementation, is a single O(log n) lookup, and then getting to the actual values is nothing but a file-seek (e.g. fseek(data_file_handle, row_index * row_size)), which is O(1). In an XML file, the most efficient way is to run a SAX parser over your document, doing an awful lot of reads and seeks before you get to your actual data; you can hardly get this any better than O(n), unless you use indexes, but then, you'd have to rebuild the entire index for every insertion (see below).

Inserting is even worse. Relational databases do not guarantee row order, which means they can just append new rows, or overwrite any rows marked as 'deleted'. This is extremely fast: the DB can just keep a pool of writable locations around; getting an entry from the pool is O(1) unless the pool is empty; worst case, the pool is empty and a new page has to be created, but this too is O(1). By contrast, an XML-based database would have to move everything after the insertion point to make room; this is O(n). When indexes come into play, things become even more interesting: typical relational-database indexes can be updated with relatively low complexity, say O(log n); but if you want to index your XML files, every insertion potentially changes the on-disk location of every value in the document, so you have to rebuild the entire index. This also goes for updates, because updating, say, an element's text content, can change its size, which means the consecutive XML has to shift. A relational database doesn't have to touch the index at all if you update a non-indexed column; an XML database would have to rebuild the entire index for each update that changes the size of the updated XML node.

Those are the most important downsides, but there are more. XML is very verbose, which is good for server-to-server communication, because it adds safety (the receiving server can perform all sorts of integrity checks on the XML, and if anything went wrong in the transfer, the document is unlikely to validate). For mass storage, however, this is killing: it is not uncommon to have 100% or more overhead for XML data (it is not uncommon to see overhead ratios in the 1000% range for things like SOAP messages), while typical relational DB storage schemes have only a constant overhead for table metadata, plus a tiny bit per row; most of the overhead in relational databases comes from fixed column widths. If you have a terabyte of data, a 500% overhead is simply unacceptable, for many reasons.

Title: Using XML as data storage


答:
We will have about 200 computers (most on the same network) that will each send, via HTTP POST, around 5000 requests/day. With each request containing about 300 bytes of data.

That's about 10 req/s. So it's clear that you don't need to switch.

Real life benefits of switching (besides getting valuable experience)? Well, as you said, you're hosting on Amazon. With node.js you'll have less load, meaning you could even use a micro instance for that kind of load, saving you some money. Also, being an asynchronous framework, it can reduce latency, for example by sending the response before saving to the database.


答:
keep them at bay and still deliver great work

Good luck with that.  I started my own company and that's really all I can suggest.

Hopefully in situations like this, the engineers band together and if theres a real issue, either a technical project manager, a technical product manager, an architect or your own dev manager can understand the scope of your work, and keep nontechnical people out of your way.

But it doesnt always work that way.  I worked for a huge tech company once where the manager WAS supposedly technical and when the devs complained about non stop meetings with 4 different project managers day in and day out his response was - OK so you want MORE meetings with project managers.

I feel that over the last 10 years technical "talent" as in actual talent has been incredibly marginalized by the business side of software organizations and this is a problem for us careerwise.

Managing high paid developers with low paid business people is like sending your kid sister to lion taming school, it just doesnt work.

But one solution I will definitely side against, is lying.  I have seen really good developers try and ward off managers by filling them with stories that have no basis technically to get them to go away.  Dont do this, if you do, you have sold your soul, and thats worse than having a crappy job.


问:
Algorithmic problem - quickly finding all #'s where value %x is some given value
Problem I'm trying to solve, apologies in advance for the length:

Given a large number of stored records, each with a unique (String) field S. I'd like to be able to find through an indexed query all records where Hash(S) % N == K for any arbitrary N, K (e.g. given a million strings, find all strings where HashCode(s) % 17 = 5. Is there some way of memoizing this so that we can quickly answer any question of this form without doing the % on every value?

The motivation for this is a system of N distributed nodes, where each record has to be assigned to at least one node. The nodes are numbered 0 - (K-1) , and each node has to load up all of the records that match it's number:

If we have 3 nodes

Node 0 loads all records where Hash % 3 ==0

Node 1 loads all records where Hash % 3 ==1

Node 2 loads all records where Hash % 3 ==2

adding a 4th node, obviously all the assignments have to be recomputed -

Node 0 loads all records where Hash % 4 ==0

...

etc

I'd like to easily find these records through an indexed query without having to compute the mod individually.

The best I've been able to come up with so far:

If we take the prime factors of N (p1 * p2 * ... )

if N % M == I then p % M == I % p for all of N's prime factors

e.g. 10 nodes :

N % 10 == 6 then

N % 2 = 0 == 6 %2

N % 5 = 1 == 6 %5

so storing an array of the "%" of N for the first "reasonable" number of primes for my data set should be helpful. For example in the above example we store the hash and the primes

HASH  PRIMES (array of %2, %3, %5, %7, ... ])

16    [0 1 1 2 .. ]

so looking for N%10 == 6 is equivalent to looking for all values where array[1]==1 and array[2] == 1.

However, this breaks at the first prime larger than the highest number I'm storing in the factor table. Is there a better way?

答:
Unless I've misunderstood something, your conjecture is incorrect.

If we take the prime factors of N (p1 * p2 * ... )

if N % M == I then p % M == I % p for all of N's prime factors

How did you come up with that?

Let's say N = 36 and M = 6

The prime factorization of N = 2 * 2 * 3 * 3. 36 % 6 = 0

According to your statement, the following should hold:

```<code>p % 6 = 0 % p = 0
</code>```

But clearly, this is not the case: 2 % 6 = 2 != 0

Body:
Unless I've misunderstood something, your conjecture is incorrect.

If we take the prime factors of N (p1 * p2 * ... )

if N % M == I then p % M == I % p for all of N's prime factors

How did you come up with that?

Let's say N = 36 and M = 6

The prime factorization of N = 2 * 2 * 3 * 3. 36 % 6 = 0

According to your statement, the following should hold:

p % 6 = 0 % p = 0

But clearly, this is not the case: 2 % 6 = 2 != 0


答:
Unit testing the code relying on your DAL should be straight-forward: use the repository pattern to decouple your business layer from your ORM. Provide your POCOs by an abstract repository, then you can either provide a "real" repository in production (which uses your ORM), or a mock repository for testing purposes which delivers just test-data POCOs without any DB access. Using an ORM which works with POCOs here has the advantage that you can easily create that objects in memory, without the need to rely on the ORM.

A different question is how to automatically test methods like "AddCustomer", assumed that this method contains only database or ORM related code. Having a short look into the PetaPoco documentation and source code, it seems to support just one database with in-memory capabilities: SqlLite. So I guess you could set up a lightweight SqlLite instance for your testdata and write your tests against this.

Theoretically, you could do this also with a full-blown relational DB system like Oracle or MS SQL server, but that option is often too slow and needs too much administrative overhead to be practical. If you want trying this route anyway, I suggest you have a look at DBUnit.NET, which supports this approach.

Whatever you will do, it may be a good idea to separate those two cases in your code: write (1) code pulling the needed objects from your DB into memory, and (2) separate code for doing the business logic, without any DB access. Surely you will need (3) code that manages (1) and (2)to make them work together, but (1) and (2) could be tested then more easily in isolation.

Title: How do I make code bound to an ORM testable?

Body:
In Test Driven Development, how do I make code bound to an ORM testable?

I am using a Micro-ORM (PetaPoco) and I have several methods that interact with the database like:

AddCustomer

UpdateRecord

etc.

I want to know how to write a test for these methods. I searched YouTube for videos on writing a test for DAL, but I didn't find any.

I want to know which method or class is testable and how to write a test before writing the code itself.


答:
Because you were never taught how to plan.

Planning is a skill, just like coding or writing. But somehow it is left out of nearly every curriculum.

It needs to be learned and practiced, and your estimates of your own capabilities need to be continuously updated. This is why work practices like Agile emphasize measuring your past actual work and comparing it to your estimates, so that you can improve your planning abilities.

As others have said, you need to account not only for the task, but for all its predecessors, attendant tasks (e.g., learning how to do X), and you need to be cognizant of your own internal mental biases that will prevent you from correctly accounting for the way you actually do work.

Train on it, and who knows, you might get better.


问:
Is Flash disappearing?
http://w3techs.com/technologies/details/cp-flash/all/all

People don't use Flash anymore? Why?

答: Most things Flash is/was used for can be done with HTML5 and Javascript - and unlike Flash, it will work on iOS devices.</p>

Title: Is Flash disappearing?


答:
GLX is necessary in Linux, since it is the glue between OpenGL and the running X server.

Certainly, GLX is fairly complex for beginners, especially when the goal is learning OpenGL, and nothing more.

All libraries out there that allow OpenGL rendering uses GLX, but they wraps GLX calls in a way to simplify OpenGL-enabled window creation.

I suggest to setup your application with GLUT, since you can create a window and manage system events (i.e. Key inpus). Additionally, GLUT is available for other systems also, allowing you to port you application somewhere else.

Title: Linux OpenGL programming, should I use GLX or any other?

Body:
I'm new to OpenGL and found that there are a lot of libraries to do that in C,
and I also found that glx is most friendly with Linux X Server, I just want to do basic stuff, and I cannot find any tutorials for GLX.

Is GLX a bad thing? I just want to do some small graphical things without installing many libraries and getting confused. Can anyone suggest me something which has tutorials and simple to compile?

I found a link with an example with GLX and it worked perfect with no errors: anyone please suggest where I can find nice documentation or any better libraries.


答:
Flash isn't supported on iOS, and Adobe just stopped supporting it on Android 4.1. Unless your website is such that it only makes sense on a desktop PC, you have to pay attention to the mobile market, and therefore you can't ONLY use flash. If there's something else that will do the job, that works both on the desktop and mobile, why would you use Flash at all?

That's not to say that every use of Flash can be easily and directly replaced with other technologies, but you can build a really nice web site lots of ways. Flash used to be the most popular and well supported (lots and lots of folks had the Flash plugin installed), but there are other ways to do cool stuff now - they aren't exactly the same, but they can make for a nice website and not necessarily need a plugin.

Title: Is Flash disappearing?

Body:
http://w3techs.com/technologies/details/cp-flash/all/all

People don't use Flash anymore? Why?


问:
What kinds of visual content, tables or diagrams might I want to include in my Project Architecture Document?
Besides logical and physical architecture diagrams, comps / mockups and tables for expected network load between components and various data schemas, what kinds of visual content, tables or diagrams might I want to include in my Project Architecture Document?

The specific project is an integration of 3rd party social networking features into a fashion site.

Please post example graphics. Thanks.

答:
Check out the 4+1 Architectural View Model:

Wikipedia entry

Original paper

I find it inspiring for answering the kind of questions you are probably looking after. Adapt to your needs.


问:
Is a 1:* write:read thread system safe?
Theoretically, thread-safe code should fix race conditions. Race conditions, as I understand it, occur because two threads attempt to write to the same location at the same time.

However, what about a threading model in which a single thread is designed to write to a location, and several slave/worker threads simply read from the location?

Assuming the value/timing at which they read the data isn't relevant/doesn't hinder the worker thread's outcome, wouldn't this be considered 'thread safe', or am I missing something in my logic?

答:
There are two problems:

If there is more than a single value being written, then without synchronization the reading threads could see partially written and thus inconsistent data. Even single values could be read in a partially written state that corresponds to none of the legitimate values (e.g. in Java, writing to double and long fields is not guaranteed to be atomic).

Reading threads could get outdated values for an arbitrarily long time after it's been written, due to caching. If that's not a problem, why have a writing thread at all?

Title: Is a 1:* write:read thread system safe?


答:
There are more problems than that.

write may not be atomic, that is a thread could see a partially updated value

even if all writes are atomic, you may get in the situation where you write A then B but another thread see the new B and the old A. You need some synchronizations instructions to ensure that you see everything that you want. Those instructions may be needed in both threads, not just the writer or the reader one.

Title: Is a 1:* write:read thread system safe?

Body:
Theoretically, thread-safe code should fix race conditions. Race conditions, as I understand it, occur because two threads attempt to write to the same location at the same time.

However, what about a threading model in which a single thread is designed to write to a location, and several slave/worker threads simply read from the location?

Assuming the value/timing at which they read the data isn't relevant/doesn't hinder the worker thread's outcome, wouldn't this be considered 'thread safe', or am I missing something in my logic?


问:
Best approach for utility class library using Visual Studio
I have a collection of classes that I commonly (but not always) use when developing WPF applications.  The trouble I have is that if I want to use only a subset of the classes, I have three options:

Distribute the entire DLL.  While this approach makes code maintenance easier, it does require distributing a large DLL for minimal code functionality.

Copy the classes I need to the current application.  This approach solves the problem of not distributing unused code, but completely eliminates code maintenance.

Maintain each class/feature in a separate project.  This solves both problems from above, but then I have dramatically increased the number of files that need to be distributed, and it bloats my VS solution with tiny projects.

Ideally, I'd like a combination of 1 & 3:  A single project that contains all of my utility classes but builds to a DLL containing only the classes that are used in the current application.

Are there any other common approaches that I haven't considered?  Is there any way to do what I want?

Thank you.

答:
The way I've done this in the past (on other systems) is using a repository.  The common files are all in a library part of the repo, but each solution maps them to an individual project.

That way, all solutions all use the same source code, but each solution only uses the files it needs.

This MS blog post tells you how to do it (for VS2005).

Note that if you do this, you need to make sure that all common functionality is completely covered by unit tests.  Otherwise, changing the functionality of one of these common files in a way that only one of the including solutions needs could break multiple solutions.

ContentLicense: CC BY-SA 4.0


答: The best explanation of Node async is the Node Beginners book. Its free (but worth the $10). It'll explain how to write your node servers and is very well written.</p>


答:
Flash has a number of downsides:

It is proprietary

It doesn't integrate well with the surrounding document structure

It doesn't come built into the browser

It is mostly opaque to search engines, screen readers, and other non-desktop-browser user agents

Back in the days, Flash was the only viable way of doing what people do with it - animations, multimedia, interactive vector graphics, reliable fonts, etc. But today, we have modern browsers with much richer styling possibilities, a decent amount of standardization, fast Javascript engines, and APIs for vector graphics, sound and video, and even 3D graphics (although I wouldn't consider this one quite ready for prime time yet) - almost all the reasons for using Flash are gone, but the downsides remain.

Title: Is Flash disappearing?


问:
Is it OK to mix C and C++ in an interview?
If I am asked in an interview to write down some code, should I completely stick with C++ or is it acceptable to "mix" the two to write easy code as it comes to my mind?

I'll explain it: if I'm asked to create a "stack" data type, a C++ class is perfectly suited, while if I need to parse some strings a strtok/sscanf is far easier than STL. On the other hand, if I need a generic container STL and templates are the way to go.

Everything can be done in C or in C++, but in an interview I can't code everything or remember every standard/STL function. What is an acceptable tradeoff?

答:
If I am asked in an interview to write down some code, should I completely stick with C++ or is it acceptable to "mix" the two to write easy code as it comes to my mind?

That entirely depends on what kind of job you are applying for and which language they expect you to use. Generally, if you are writing C++, it is best to stick to C++ as far as possible. I would however expect every C++ programmer to know at least a bit of C (and vice versa).

I'll explain it: if I'm asked to create a "stack" data type, a C++ class is perfectly suited, while if I need to parse some strings a strtok/sscanf is far easier than STL. On the other hand, if I need a generic container STL and templates are the way to go.

If they expect you to write a whole working data type during the interview, you should be wary. It is good if they ask you about technical details, but if they expect you to spend hours of writing programs during the interview, that likely says something bad about the employer.

If you use scanf(), you have probably made a big mistake no matter if C or C++. You better explain to the interviewer that you are just writing something quick & dirty and would never use scanf in production code. There are many pit falls with various C library functions.

The interviewer shouldn't expect you to remember every function in the C and C++ standard librarier, but they should expect you to know which ones that are blatantly dangerous. gets(), getchar(), scanf(), setjmp() etc.


问:
How much detail is in a good UI regression test?
We use a detailed step-by-step user-interface regression test for our commercial web application.  It has a "backbone" test for the most used / most important parts of the system, with optional tests for specific areas of functionality.  Using this plan has definitely helped us ensure high quality software.

But, having very specific tests can be counter-productive.  The tester concentrates on following the test and will completely miss usability issues, or not notice fairly obvious problems such as the bottom part of a page that is missing.

By contrast, some of the best UI testing happens when building a demo of a new feature.  I often do my own best testing by pretending to demonstrate the system to an imaginary prospect.  Yet when I tell the testers, "Just demonstrate the system to yourself" they don't cover nearly as much functionality as they do with a detailed point-by-point test.

I'm repeatedly asked to provide more and more detail in the test plan so that a new untrained tester can test with it without asking any questions.  Yet details seem to be counter-productive.  How much detail do you put in a regression test to make it effective?  How do you write tests that make the tester focus more on the system than on checking off items on the test?

答:
You cannot command someone to be innovative. If you have only testers in your team without developing own ideas for good tests, I don't think a better test plan will solve that problem for you. Either they need more experience and training, or you need different people in your team.

Said that, I think you should have both:

a very detailed step-by-step check list of things where you want testers to have an eye on

some general questions / guidelines, for example, about testing usability or about things not explicitly mentioned in your plan, or a demand for creating missing points in the checklist by themselves.

Make clear that you expect your team not only to focus on point 1, but also on point 2, but don't expect too much because of what I wrote at the beginning.


问:
How can you tell whether to use Composite Pattern or a Tree Structure, or a third implementation?
I have two client types, an "Observer"-type and a "Subject"-type. They're both associated with a hierarchy of groups.

The Observer will receive (calendar) data from the groups it is associated with throughout the different hierarchies. This data is calculated by combining data from 'parent' groups of the group trying to collect data (each group can have only one parent).

The Subject will be able to create the data (that the Observers will receive) in the groups they're associated with.
When data is created in a group, all 'children' of the group will have the data as well, and they will be able to make their own version of a specific area of the data, but still linked to the original data created (in my specific implementation, the original data will contain time-period(s) and headline, while the subgroups specify the rest of the data for the receivers directly linked to their respective groups).

However, when the Subject creates data, it has to check if all affected Observers have any data that conflicts with this, which means a huge recursive function, as far as I can understand.

So I think this can be summed up to the fact that I need to be able to have a hierarchy that you can go up and down in, and some places be able to treat them as a whole (recursion, basically).

Also, I'm not just aiming at a solution that works. I'm hoping to find a solution that is relatively easy to understand (architecture-wise at least) and also flexible enough to be able to easily receive additional functionality in the future.

Is there a design pattern, or a good practice to go by, to solve this problem or similar hierarchy problems?

EDIT:

Here's the design I have:

The "Phoenix"-class is named that way because I didn't think of an appropriate name yet.

But besides this I need to be able to hide specific activities for specific observers, even though they are attached to them through the groups.

A little Off-topic:

Personally, I feel that I should be able to chop this problem down to smaller problems, but it escapes me how. I think it's because it involves multiple recursive functionalities that aren't associated with each other and different client types that needs to get information in different ways. I can't really wrap my head around it. If anyone can guide me in a direction of how to become better at encapsulating hierarchy problems, I'd be very glad to receive that as well.

答:
With the limited view we have of the usage or implementation requirements of your system it's hard to get too specific. For example, things that would come into consideration might be:

is the system highly concurrent (lots of users)?

what is the read/write ratio of data access? (high read, low write is common)

As for patterns etc., I would worry less about what exact patterns crop up in your solution, and more about the design of the actual solution. I think knowledge of design patterns is useful, but not the be-all and end-all: to use a writer analogy, design patterns are more like a dictionary of commonly seen phrases, rather than a dictionary of sentences you must write an entire book from.

Your diagram looks generally ok to me.

There's one mechanism you've not mentioned and that is of having some sort of cache in your hierarchy. Obviously you must implement this with great care, but it could significantly improve the performance of your system. Here's a simple take on it (caveat emptor):

For each node in your hierarchy, store inherited data with the node. Do this lazily or pro-actively, that's up to you. When an update is made the hierarchy, you can either regenerate the cache data for all affected nodes there and then, or set 'dirty' flags in the appropriate places, and have the affected data lazily re-generated when necessary.

I have no idea how appropriate this is in your system, but may be worth considering.

Also, this question on S.O. may be relevant:

https://stackoverflow.com/questions/1567935/how-to-do-inheritance-modeling-in-relational-databases

OwnerDisplayName: Aske B.


问:
Why is it you never get as much done as you'd planned?
I always start the day thinking "I'll easily get this done by the end of the day" and set what looks like a realistic target.

So why do I never hit it? The task always ends up taking 3x longer due to unforeseen bugs, last minute changes etc.

Is it just me?  I don't seem to be getting any better predicting what can be done in a day.

答:
Because you aren't planning correctly. Ouch.

I bet if you keep a running total of how much you slip by (on paper even), then adjust your estimates up by that %, you'll be able to plan correctly.

FWIW, software is notoriously hard to estimate. McConnell (of Code Complete fame) has a book out on it even.


答:
Technically speaking, a regression test should not be looking for usability issues. It may catch deviations from the UI design as part of the test cases but usability issues are best determined by UI design specialists. UI regression tests are usually performed by QA (testers), as you know.

If the product is too big for a detailed UI design, the UI designer produce should produce guidelines that the development team should follow and the QA should check for. For example, "Each page should contain a header with A, B and C" or "When asking for an address, it should have these fields laid out in this way".

It may be better to supply the UI verification steps in a different way. For example, instead of giving steps, include screen shots of that the app should look like (which should catch the bottom portion of a page missing).

You may also want to consider an automated UI testing tool like Selenium. This can automate much of the repetitive testing aspect you are capturing in the steps and free you and your testers up to look for harder to reproduce or more critical issues.

Title: How much detail is in a good UI regression test?

Body:
We use a detailed step-by-step user-interface regression test for our commercial web application.  It has a "backbone" test for the most used / most important parts of the system, with optional tests for specific areas of functionality.  Using this plan has definitely helped us ensure high quality software.

But, having very specific tests can be counter-productive.  The tester concentrates on following the test and will completely miss usability issues, or not notice fairly obvious problems such as the bottom part of a page that is missing.

By contrast, some of the best UI testing happens when building a demo of a new feature.  I often do my own best testing by pretending to demonstrate the system to an imaginary prospect.  Yet when I tell the testers, "Just demonstrate the system to yourself" they don't cover nearly as much functionality as they do with a detailed point-by-point test.

I'm repeatedly asked to provide more and more detail in the test plan so that a new untrained tester can test with it without asking any questions.  Yet details seem to be counter-productive.  How much detail do you put in a regression test to make it effective?  How do you write tests that make the tester focus more on the system than on checking off items on the test?


问:
Should an image be able to resize itself in OOP?
I'm writing an app that will have an Image entity, and I'm already having trouble deciding whose responsibility each task should be.

First I have the Image class. It has a path, width, and other attributes.

Then I created an ImageRepository class, for retrieving images with a single and tested method, eg: findAllImagesWithoutThumbnail().

But now I also need to be able to createThumbnail(). Who should deal with that? I was thinking about having an ImageManager class, which would be an app-specific class (there would also be a third party image manipulation reusable component of choice, I'm not reinventing the wheel).

Or maybe it would be 0K to let the Image resize itself? Or let the ImageRepository and ImageManager be the same class?

What do you think?

答:
I think it would have to be part of the Image class, as resizing in an external class would require the resizer to know the implementation of the Image, thereby violating encapsulation.  I'm assuming Image is a base class, and you'll wind up with separate subclasses for concrete image types (PNG, JPEG, SVG, etc).  Therefore, you'll either have to have corresponding resizing classes, or a generic resizer with a switch statement that resizes based on the implementation class -- a classic design smell.

One approach might be to have your Image constructor take a resource containing the image, and height and width parameters and create itself appropriately.  Then resizing could be as simple as creating a new object using the original resource (cached inside the image) and the new size parameters.  E.g. foo.createThumbnail() would simply return new Image(this.source, 250, 250). (with Image being the concrete type of foo, of course).  This keeps your images immutable and their implementations private.


问:
Name for this antipattern? Fields as local variables
In some code I'm reviewing, I'm seeing stuff that's the moral equivalent of the following:

```<code>public class Foo
{
    private Bar bar;

    public MethodA()
    {
        bar = new Bar();
        bar.A();
        bar = null;
    }

    public MethodB()
    {
        bar = new Bar();
        bar.B();
        bar = null;
    }
}
</code>```

The field bar here is logically a local variable, as its value is never intended to persist across method calls. However, since many of the methods in Foo need an object of type Bar, the original code author has just made a field of type Bar.

This is obviously bad, right?

Is there a name for this antipattern?

答:
I would call it unnecessary large scope for a variable.
This setting also allows for race conditions if multiple threads access MethodA and MethodB.</p>


答:
The primary concern here would be concurrency--If the Foo is being used by multiple threads, you have a problem.

Beyond that, it's just silly--local variables manage their own life cycles perfectly well.  Replacing them with instance variables that need to be nullified when they are no longer useful is an invitation to error.

Title: Name for this antipattern? Fields as local variables

Body:
In some code I'm reviewing, I'm seeing stuff that's the moral equivalent of the following:

```<code>public class Foo
{
    private Bar bar;

    public MethodA()
    {
        bar = new Bar();
        bar.A();
        bar = null;
    }

    public MethodB()
    {
        bar = new Bar();
        bar.B();
        bar = null;
    }
}
</code>```

The field bar here is logically a local variable, as its value is never intended to persist across method calls. However, since many of the methods in Foo need an object of type Bar, the original code author has just made a field of type Bar.

This is obviously bad, right?

Is there a name for this antipattern?


答:
This is obviously bad, right?

Yea.

It makes the methods non-reentrant, which is a problem if they are called on the same instance recursively or in a multi-threaded context.

It means that state from one call leaks to another call (if you forget to reinitialize).

It makes the code hard to understand because you have to check for the above to be sure what the code is actually doing.  (Contrast with using local variables.)

It makes each Foo instance bigger than it needs to be.  (And imagine doing this for N variables ...)

Is there a name for this antipattern?

IMO, this is does not deserve to be called an antipattern.  It is just a bad coding habit / a misuse of Java constructs / crap code.  It is the sort of thing that you might see in an undergraduate's code when the student has been skipping lectures and/or has no aptitude for programming.  If you see it in production code, it is a sign that you need to do a lot more code reviews ...

For the record, the correct way to write this is:

```<code>public class Foo
{
    public methodA()
    {
        Bar bar = new Bar();  // Use a >>local<< variable!!
        bar.a();
    }

    // Or more concisely (in this case) ...
    public methodB()
    {
        new Bar().b();
    }
}
</code>```

Notice that I've also fixed the method and variable names to conform to the accepted style rules for Java identifiers.

Body:
This is obviously bad, right?

Yea.

It makes the methods non-reentrant, which is a problem if they are called on the same instance recursively or in a multi-threaded context.

It means that state from one call leaks to another call (if you forget to reinitialize).

It makes the code hard to understand because you have to check for the above to be sure what the code is actually doing.  (Contrast with using local variables.)

It makes each Foo instance bigger than it needs to be.  (And imagine doing this for N variables ...)

Is there a name for this antipattern?

IMO, this is does not deserve to be called an antipattern.  It is just a bad coding habit / a misuse of Java constructs / crap code.  It is the sort of thing that you might see in an undergraduate's code when the student has been skipping lectures and/or has no aptitude for programming.  If you see it in production code, it is a sign that you need to do a lot more code reviews ...

For the record, the correct way to write this is:

public class Foo
{
    public methodA()
    {
        Bar bar = new Bar();  // Use a >>local<< variable!!
        bar.a();
    }

    // Or more concisely (in this case) ...
    public methodB()
    {
        new Bar().b();
    }
}

Notice that I've also fixed the method and variable names to conform to the accepted style rules for Java identifiers.


答:
I've used PetaPoco in an application and what I ended up doing was just abstracting an interface for the Database object which just exposed the methods that I actually use (since there are 100s of them and I only actually needed 10-15).

This allowed me to provide mock implementations of that interface in unit tests and in my DI container I simply bound the Database object to the IDatabase interface.

I wouldn't bother implementing the repository pattern, abstracting an IDatabase interface will essentially become a generic repository anyway.

The resulting annoyance with this led me to create my own Micro-ORM (MicroLite) which is designed to allow ease of testing which you can find on GitHub and NuGet (note: at present it only supports MsSql).


答:
I think that you are on the right trail as far as separating the logic and actions to be performed on these services.  Jgauffin is correct in stating that you should give the "integrators" a better naming convention.  i_objectName_whatObjectDoes is a good start and makes it much easier for future developers to know what object does what function.

When it comes to code separation,  you might want to look in to making use of DTO's, Data-layers, and Object Managers.  This makes your solution more readable.  Remember to keep your DTO's, Datalayers and Managers in sepaerate projects and include them in your solution.


答:
(1)  I would say it's not good.

It's performing manual house keeping that the stack can do automatically with local variables.

There is no performance benefit since "new" is called each method invocation.

EDIT: The memory footprint of the class is larger because the bar pointer is always taking up memory over the lifetime of the class. If the bar pointer was local, then it would only use memory for the lifetime of the method call. The memory for the pointer is just a drop in the ocean, but it's still an unnecessary drop.

The bar is visible to other methods in the class. Methods that don't use bar shouldn't be able to see it.

State-based errors. In this particular case state base errors should only occur in multi-threading since "new" is called each time.

(2) I don't know if there's a name for it since it's actually several issues, not one.

--manual housekeeping when automatic is available

--unnecessary state

--state that lives longer that it's lifetime

--visibility or scope is too high


问:
How important is Discrete Mathematics for a Computer Scientist?
As the title says,

How important is Discrete Mathematics for a Computer Scientist?
Background: I'm pursuing a Master's degree with a focus on fundamentals such as Algorithms, Complexity and Computability Theory and Programming Languages to get a good foundation for working in the field of Parallel Computing.

Some more background: My university grants a lot of freedom in the choices of courses for my Master's degree. It's officially called "Software Engineering", but due to a the broad range of electives, a different focus is possible. Interestingly, none of the electives is a lecture in Math! I'm thinking about doing a course about Discrete Mathematics that would take half a semester to complete successfully, even if I can't use it for my degree. So with this question I'm trying to find out if the effort is justifiable.

答:
As a Computer Scientist looking to get a Master's degree with focus on "Algorithms, Complexity and Computability Theory and Programming Languages" I would say Discrete Mathematics is very important.

Discrete math will help you with the "Algorithms, Complexity and Computability Theory" part of the focus more than programming language.  The understanding of set theory, probability, and combinations will allow you to analyze algorithms.  You will be able to successfully identify parameters and limitations of your algorithms and have the ability to realize how complex a problem/solution is.

As far as the programming language, discrete math doesn't touch on how to actually program; but rather it can be used for software system design specification.  I used "ZED" in university, and it was dealing with designing a system using set theory.  I'm not sure what percentage of software systems are designed with set theory these days though.

The last important concept to grab out of discrete math is boolean algebra.  This is very useful not only for creating logical solution, but it is very useful in programming too.  Software can be made/broke simply on the boolean logic in it.

Overall, discrete math is not a numbers class for the most part.  It makes you use your brain in ways no other classes do.  It is a logical thinking class and you must have patience if doing proofs/logic computations don't come easy to you.  I've seen people change majors because they couldn't think "abstractly" enough to get through the course.

In short, I would make a stance that discrete math would be important class to take for a Computer Scientist/Software Engineer.


问:
ISTQB terminology question (Defect)
According to ISTQB (and few more sources + wiki ), a defect/bug is the actual cause of error in software, e.g. incorrect statement, logical or semantic error. The actual definion is: a flaw in the system or component that could lead to the failure.
But what about specification bugs? I cannot relate to it. Specification bugs are quite common but if the programmer implements software according to spec with a bug, it is not his fault (IMHO). But then the definion could not apply and I am sure it must have been addressed somehow. Could you help me to understand this?</p>

答:
If you're looking for formal terminology, I'd forget the term "bug" all together. Only consider mistake, error, fault, and failure. Based on IEEE610.12-90, the definitions are (as provided in the Software Engineering Body of Knowledge:

Mistake: A human action that produces an incorrect result.

Fault: An incorrect step, process, or data definition in a computer program

Error: A difference...between a computed result and the correct result

Failure: The [incorrect] result of a fault

Your "bug" is actually what is formally called a fault. However, that fault was injected by a mistake in an earlier process. In your example, the specification contained a mistake.

Title: ISTQB terminology question (Defect)


问:
Was Xcode created with Xcode?
I don't want to get too philosophical here (like did God create God?), but how did Apple create Xcode? Would it have been possible for them to use Xcode to create Xcode? Or would they have to use another code program (and what might that be?). In general, how does that work with code editors?</p>

答:
No, they would not be able to launch Xcode to use it before they created it.

They had to use another editor like (say) vim which already existed. The original editors were presumably written straight to disk in machine code or something but now that we have editors we don't need to worry about that anymore.

Title: Was Xcode created with Xcode?


答: Xcode now is probably made with Xcode. If you're wondering how that's bootstrapped, at some point in the past a version of (not even Xcode or Project Builder, but Interface Builder which in the early days of NeXT was the whole of the IDE) would've been built just using Objective-C source files, edited in whatever text editor, and Make/gcc.</p>

Title: Was Xcode created with Xcode?

Body: I don't want to get too philosophical here (like did God create God?), but how did Apple create Xcode? Would it have been possible for them to use Xcode to create Xcode? Or would they have to use another code program (and what might that be?). In general, how does that work with code editors?</p>


答: Something I often find myself doing is getting distracted by random stuff that is unrelated to what I'm doing. A todo list can help with that; when you think of something, write it down and do it after you finish what's in front of you.</p>