วันศุกร์ที่ ๓๑ สิงหาคม พ.ศ. ๒๕๕๐

การออกแบบ xml เพื่อใช้กับ DataSet อ็อบเจ็ค (XML structure for DataSet)

มีคนถามมาว่าทำไมมีแต่บทความพื้นๆ จัง คือ ที่จริงผมตั้งใจจะเรียงลำดับตามหนังสือที่ผมอ่านครับ แต่เมื่อมีคนถามเข้า และประจวบกับผมจะเอาความรู้บางอย่างที่ใช้ในการทำงาน มาเก็บเอาไว้ เพราะผมลืมสิ่งที่ทำไปแล้วง่ายมากๆ วันนี้มีโอกาสได้ใช้เกี่ยวกับไฟล์ XML ซึ่งใช้ในการเก็บข้อมูลบางอย่าง แล้วต้องมีการนำข้อมูลในไฟล์ขึ้นมาใช้

โดยทั่วไป ถ้าเรานึกถึงไฟล์ เราก็ต้องนึกถึง เนมสเปส (Namespace) ที่ชื่อ IO ดังนั้นในการไปติดต่อกับไฟล์ XML จึงต้องใช้อ็อบเจ็คของคลาสใน IO ไปติดต่อ แต่ผมต้องการเขียนโค้ดสั้นๆ และง่ายๆ จึงใช้ DataSet ตัวเดียว แทนการใช้ Syste.IO มาใช้ในการดึงข้อมูลจากไฟล์ XML และทั้งเก็บข้อมูลไว้ในตัวมัน ซึ่งสะดวกจริงๆ ครับ ไม่ต้องมานั่งหา node เพื่อดึงข้อมูล

ก่อนอื่นเราต้องสร้างไฟล์ XML ของเราขึ้นมาก่อนครับ ผมขอยกตัวอย่างและอธิบายเลยนะครับ
โครงสร้าง XML ต่อไปนี้ คือตัวอย่างของการสร้าง dataset ที่มี 1 ตาราง 1 คอลัมน์ และ 1 แถว

<?xml version="1.0" encoding="utf-8" ?>
<datasetName>
<tableName>
<columnName>data on row</columnName>
</tableName>
</datasetName>

ถ้าต้องการหลายๆ แถว โครงสร้าง XML จะต้องเพิ่มตั้งส่วนที่เป็นชื่อตารางเข้าไป

<?xml version="1.0" encoding="utf-8" ?>
<datasetName>
<tableName>
<columnName>data on row1</columnName>
</tableName>
<tableName>
<columnName>data on row2</columnName>
</tableName>
<tableName>
<columnName>data on row3</columnName>
</tableName>
</datasetName>


ส่วนการเพิ่มคอลัมน์ก็ต้องเพิ่มชื่อคอลัมน์ไปทุกๆ แถวๆเลยนะครับ

<?xml version="1.0" encoding="utf-8" ?>
<datasetName>
<tableName>
<columnName1>data on row1</columnName1>
<columnName2>data on row1</columnName2>
</tableName>
<tableName>
<columnName1>data on row2</columnName1>
<columnName2>data on row1</columnName2>
</tableName>
<tableName>
<columnName1>data on row3</columnName1>
<columnName2>data on row1</columnName2>
</tableName>
</datasetName>


และสุดท้ายก็เป็นที่รู้กันครับว่า ใน dataset สามารถเก็บตารางได้หลายตาราง ดังนั้นต้องแสดงกรณีต้องการหลายๆ ตารางครับ โครง XML เป็นดังนี้

<?xml version="1.0" encoding="utf-8" ?>
<datasetName>
<!-- Table 1 -->
<tableName1>
<columnName1>data on row1</columnName1>
<columnName2>data on row1</columnName2>
</tableName1>
<tableName1>
<columnName1>data on row2</columnName1>
<columnName2>data on row2</columnName2>
</tableName1>
<tableName1>
<columnName1>data on row3</columnName1>
<columnName2>data on row3</columnName2>
</tableName1>
<!-- Table 2 -->
<tableName2>
<columnName1>data on row1</columnName1>
<columnName2>data on row1</columnName2>
<columnName3>data on row1</columnName3>
</tableName2>
<tableName2>
<columnName1>data on row2</columnName1>
<columnName2>data on row2</columnName2>
<columnName3>data on row2</columnName3>
</tableName2>
</datasetName>


และสุดท้ายก็คือ การดึงข้อมูลจาก XML ไฟล์ ด้วย DataSet ซึ่งก็ง่ายนิดเดียวครับ แค่บรรทัดเดียว (สร้าง object ds ไว้ก่อนด้วยนะครับ เดี๋ยว error)

'สำหรับ VB.NET
ds.ReadXml("c:\example.xml")

//สำหรับ C#
ds.ReadXml(@"c:\example.xml");

ถ้าแก้ไขข้อมูลแล้วจะเก็บลงคืน XML ไฟล์ ก็บรรทัดเดียวอีกเหมือนกันครับ

'สำหรับ VB.NET
ds.WriteXml("c:\example.xml")

//สำหรับ C#
ds.WriteXml(@"c:\example.xml");


ลองนำไปประยุกต์ใช้ดูครับ และอย่าลืมว่า syntax ของ XML เป็นแบบ case sensitive นะครับ

วันพฤหัสบดีที่ ๒๓ สิงหาคม พ.ศ. ๒๕๕๐

Shared Source ลิขสิทธิ์แบบโอเพ่นซอร์สของไมโครซอฟต์ (Shared Source Licenses)

เรามาลองดูกันว่า Shared Source Licenses นี้ จะทำให้ชาว Open Source พอใจแค่ไหน เริ่มจากประเภทของ Licenses ที่จะแบ่งออกเป็น 2 ประเภท คือ

1. Microsoft Public License (Ms-PL) ประเภทนี้จะอนุญาตให้เราดู แก้ไข(
modify) แจกจ่าย(redistribute) ซอร์สโค้ด เพื่อการค้าหรือไม่ก็ได้ ซึ่งสามารถคิดค่าแรงให้การปรับแก้ซอร์สโค้ดได้ ไมโครซอฟต์เองก็ใช้ license นี้ กับ tool ในการพัฒนาซอฟต์แวร์, โปรแกรม และ component ต่างๆ ที่แจกฟรี เช่น IronPython, IronRuby เป็นต้น ซึ่งส่วนใหญ่พบได้ใน Codeplex.com

2. Microsoft Reciprocal License (Ms-RL) ออกแบบมาสำหรับโปรเจ็คที่มีการพัฒนาร่วมกับหลายๆ โปรเจ็ค (
collaborative development projects) ซึ่งจะเป็นการแลกเปลี่ยนผลประโยชน์ซึ่งกันและกันของแต่ละโปรเจ็ค ช่วยให้สามารถนำวิธีการ เทคโนโลยี และซอร์สโค้ดของกันแะักันมาใช้ได้ และอนุญาตให้นำไปแก้ไข แจกจ่าย เพื่อกาค้าหรือไม่ก็ได้

ก่อนหน้านี้ Ms-PL ใช้ชื่อว่า Microsoft Permissive License แต่ได้เปลี่ยนเป็น Microsoft Public License ก่อนที่จะส่งให้ Open Source Initiative (OSI) พิจารณา ซึ่งล่าสุดทาง OSI ก็ออกมารับรอง licenses ทั้ง 2 นี้แล้ว เมื่อวันที่ 12 ตุลาคม 2550 ที่ผ่านมา

ไหนๆ ก็พูดถึง licenses ใหม่ๆ ของไมโครซอฟต์แล้ว ก็พูดถึงอีก 3 แบบ ที่ไม่ได้เป็น open source บ้าง แต่ไมโครซอฟต์จะนำไปใช้กับผลิตภัณฑ์เพื่อการค้าของตัวเอง ได้แก่

Microsoft Reference License มีข้อจำกัดมากที่สุด คือ อนุญาตให้ดูหรือศึกษาซอร์สโค้ด เพื่อเรียนรู้วิธีการหรือเทคโนโลยีได้เท่านั้น ห้ามนำไปแก้ไขแจกจ่าย ทางไมโครซอฟต์เองก็ได้ใช้ license ประเภทนี้ กับพวก library ในการพัฒนาซอฟต์แวร์ต่างๆ เช่น .NET Framework 3.5
Microsoft Limited Public License (Ms-LPL) เหมือนกับ Ms-PL แต่อนุญาตให้ใช้เฉพาะบน Windows เท่านั้น
Microsoft Limited Reciprocal License (Ms-LRL)
เหมือนกับ Ms-RL แต่อนุญาตให้ใช้เฉพาะบน Windows เท่านั้น

จุดเด่นที่ทางไมโครซอฟต์พัฒนา license ขึ้นมา คือ license อ่านง่าย สั้น และไม่เป็นภาษากฎหมายเกินไป ผมจะลองยกตัวอย่างเปรียบเทียบกับ GPL เวอร์ชั่น 2 ให้ดูข้างล่างนะครับ



Microsoft Permissive License (Ms-PL)

This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.

1. Definitions

The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.

A "contribution" is the original software, or any additions or changes to the software.

A "contributor" is any person that distributes its contribution under this license.

"Licensed patents" are a contributor's patent claims that read directly on its contribution.

2. Grant of Rights

(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.

(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.

3. Conditions and Limitations

(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.

(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.

(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.

(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.

(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.



GNU General Public License (GPL) version 2

Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.

Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and modification follow.

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.

1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.

You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:

a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.

b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.

c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.

In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.

3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:

a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,

b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,

c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.

If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.

4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.

6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.

7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.

It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.

This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.

8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.

9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.

10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.



นี่เป็นการแสดงให้เห็นถึง ภาษาและความสั้นของ license ของทางไมโครซอฟต์ ที่เข้าใจปัญหาของนักพัฒนาต่อตัวบทกฎหมาย และให้ความสำคัญต่อวงการ Open Source ซึ่งผมว่าเรื่องความยาวของ license เนี้ย ไอเดียเหมือนทาง Creative Commons เลย แต่กระนั้น Linus Torvalds ก็จะไม่ชอบ licenses นี้ต่อไป (แต่ถ้าเทียบกับสมัยก่อน ผมว่า Microsoft ก็ปรับตัวดีขึ้นแล้วนะ ดีกว่ามาต่อต้าน Open Source ซึ่งผมก็ไม่ชอบท่าทีแบบนั้น)

แหล่งข้อมูล :
Shared Source Licenses (Microsoft)
Shared Source (wikipedia)
Shared Source Licensing (Matusow's Blog)
Microsoft now wants its Shared Source licenses to qualify as open source (ZDNet)
Shared Source License ได้รับการรับรองจาก OSI แล้ว - Blognone
เปิดซอร์สโค้ด .NET Framework 3.5 - Blognone

วันศุกร์ที่ ๓ สิงหาคม พ.ศ. ๒๕๕๐

โอเพ่นซอร์สในแบบไมโครซอฟต์ (Open Source at Microsoft)

เมื่อกระแส Open Source มาแรงขึ้นเรื่อยๆ ตามการเจริญเติบโตของอินเตอร์เน็ต ที่พ่วงแนวคิดคำว่าอิสระ(Freedom) มาด้วย ซอฟต์แวร์และเทคโนโลยี เช่น Linux, FreeBSD, PHP, Ruby, Python, Gimp, OpenOffice เป็นต้น ก็ถูกพัฒนาจากโปรแกรมเมอร์อิสระจำนวนมากมายทั่วโลก ทำให้แนวคิดการพัฒนาซอฟต์แวร์เจริญขึ้น ด้วยแนวคิดอิสระอย่างเห็นได้ชัด เพราะไม่ถูกจำกัดด้วยความเป็นไปได้ทางธุรกิจ จนซอฟต์แวร์ Open Source มีความสามารถทัดเทียมซอฟต์แวร์ที่ผลิตเพื่อการค้า (บางทีก็เป็นผู้นำหรือจุดประกายให้เกิดกระแสต่อโลกซอฟต์แวร์ภายหลังด้วยซ้ำ) บริษัทต่างๆ จึงเริ่มมีการนำซอฟต์แวร์ Open Source มาใช้ จนค่อยๆ แย่งส่วนแบ่งตลาดค้าซอฟต์แวร์ทีละนิด ซึ่งยิ่งส่งผลต่อ Open Source community ให้เติบโตอย่างรวดเร็ว และยิ่งมีอิทธิพลต่อนักพัฒนาซอฟต์แวร์ทั่วไป เพราะ Open Source ทำให้เกิดการเรียนรู้และพัฒนาการทางซอฟต์แวร์อย่างมาก

แม้กระทั่งบริษัท Sun ก็ทนเสียงนักพัฒนา Java ทั่วโลก ที่เรียกร้องให้ Open Source ตัว java ไม่ไหว ด้วยเหตุผลหลาย เช่น การพัฒนา Java ที่ช้ากว่าที่ควร อันเนื่องมาจากโครงสร้างคณะกรรมการที่ี่ซับซ้อน (ซึ่งมีเอกชนหลายรายเข้าร่วม) หรือการไม่แพร่หลายของ Java อย่างที่ควรจะเป็น อันเนื่องมาจากลิขสิทธิ์ของ Sun เอง (ที่ผู้ประกอบการจะต้องเสียเงินจำนวนมาก สำหรับค่า license ซึ่งอาจด้วยเหตุผลนี้ ที่ทำให้ซอฟต์แวร์หรือผลิตภัณฑ์บนเซิร์เวอร์ที่ใช้เทคโยโลยีจาวา จะมีราคาค่อนข้างแพง โดยเฉพาะตัวที่ใช้กับระบบ Unix เช่น Websphere ของ IBM) หรือการพัฒนาซอฟต์แวร์อื่นๆ ที่ต้องใช้ Java ก็ติดปัญหา license ทำให้ไม่สามารถพัฒนาซอฟต์แวร์อย่างสร้างสรรได้ เช่น OpenOffice อีกทั้งเมื่อปี 2548 เกิดโครงการ Harmony ของกลุ่ม Apache ที่เป็นโครงการสร้าง Java ในแบบ Open Source และสิ่งกดดันสำคัญ คือ ความนิยมในตัว Mono (.NET Framework บน Unix) ที่เป็น Open Source เต็มตัว และถูกนำไปรวมอยู่ใน Linux อย่างแพร่หลาย (เป็นการส่งเสริม .NET ของต้นคิด Microsoft คู่แข่ง Sun นั้นเอง) ซึ่งจากปัญหาและความกดดันเหล่านี้ ทำให้ในที่สุดทาง Sun จึงได้ Open Source ตัว Java รุ่น Desktop (Standard Edition) ไปเมื่อเดือนพฤศจิกายน 2549 ปีที่แล้วนี่เอง (ชนกับ Apache ไปเลย) แต่ยังเป็น Open Source เฉพาะรุ่น Standard Edition และ Micro Edition (เวอร์ชั่น open source จะเรียกรุ่น Micro Edition ว่า phoneME ส่วนตัว JDK จะเรียกว่า OpenJDK แทน) โดยการ Open Source ที่ว่านี้ ใช้ license แบบ GPL เวอร์ชั่น 2 (นั้นแน่ หลายคนเพิ่งรู้ใช่ไหมว่าที่ผ่านมา Java ไม่ใช่ Open Source)

ทางด้าน Microsoft นั้น นอกจากจะมีการร่วมมือกับบริษัท Novell ในการพัฒนา Mono แล้ว ยังเปิดศูนย์วิจัยและสนับสนุนการพัฒนาซอฟต์แวร์ Open Source ที่ชื่อ The Open Source Lab โดยมีเว็บ Port25 เป็น Community สำหรับนักพัฒนา นอกจากนั้น Microsoft ก็ได้เปิดเว็บไซต์ที่เป็นแหล่งพัฒนาโครงการ Open Source ที่ชื่อ CodePlex อีก (คล้ายๆ SourceForge) เท่านั้นยังไม่พอ Microsoft ได้เห็นปัญหาความยุ่งยากและซับซ้อนของลิขสิทธิ์ ที่นักพัฒนาทั่วไปเข้าใจได้ยาก จึงได้คิด license ที่เป็นเนื้อหาน้อยมาก เมื่อเทียบกับ GPL (แนวคิดคล้าย Creative Common) ซึ่ง license ที่ว่านี้มีชื่อว่า Shared Source Licenses และล่าสุดเมื่อเดือนกรกฎาคม ที่ผ่านมา ในงาน O'Reilly Open Source conference นั้น ทางทีมงาน Microsoft ได้เล่าให้ฟังว่า กำลังยื่นเสนอต่อ Open Source Initiative (OSI) ให้อนุมัติ Shared Source Licenses เป็น license ที่ใช้สำหรับซอฟต์แวร์ทาง Open Source อย่างเป็นทางการ (ล่าสุด เมื่อวันที่ 12 ตุลาคม 2550 ที่ผ่านมา ทาง OSI ได้ประกาศรับรองให้ Shared Source Licenses 2 ตัว คือ Ms-PL และ Ms-RL เป็น License แบบ Open Source อย่างเป็นทางการแล้ว ดูข้อมูลเพิ่มเติมของ Shared Source Licenses ซึ่งแปลแบบคร่าวๆ ที่ Shared Source ลิขสิทธิ์แบบโอเพ่นซอร์สของไมโครซอฟต์) ทั้งหมดนี้จะเห็นได้ว่า Microsoft นั้นได้เปลี่ยนทิศทางจากการ anti open source มาเป็นการช่วยสนับสนุน open source ซึ่งผมว่าวันนี้ Microsoft มาถูกทางแล้วครับ

(link ข้างล่างทั้ง 3 ของย่อหน้านี้ ผมแนะนำให้อ่านอย่างยิ่ง)
ผมสังเกตอีกอย่างครับ ว่า บิล เกตส์์ มีท่าทีความคิดเปลี่ยนไป หลังจากเข้าพบ วอร์เรน บัพเฟตต์ (Warren Buffet) เศรษฐีอันดับ 2 ของโลก แล้วเริ่มมีพฤติกรรมไม่เหมือนเดิม ซึ่งผมก็คิดว่าดีขึ้นเรื่อยๆ นะ เช่น การตั้งมูลนิธิ, การบริจาคเงินช่วยเหลือคนติดเอดส์ในเอเชีย (มูลนิธิบิลล์และมาลินดา เกตต์ จ่าย 280 ล้านดอลลาร์ต่อสู้วัณโรค), การให้ทุนการศึกษาแบบให้เปล่า, และที่โด่งดัง คือ การไปพูดที่ ม.ฮาร์วาร์ด แล้วพูดถึงเรื่องความยากจน และความไม่เสมอภาคของมนุษย์... และถามว่าทำไมฮาร์วาร์ด ไม่มีจิตวิญญาณเรื่องนี้เพียงพอ ในเรื่องพฤติกรรมเปลี่ยนไปของบิล เกตส์ นั้น หลายๆ คนค่อนข้างจะไม่เชื่อใจว่าเค้าจริงใจ เพราะภาพที่เชิงลบของบิล เกตส์ ยังคงฝังลึกอยู่ในใจ แต่ผมก็เชื่อโดยส่วนตัวว่าการที่ Microsoft เข้าสู่โลก Open Source นั้น ก็เพราะบิล เกตส์ มีทัศนะคติต่อโลกที่เปลี่ยนไปนั้นเอง ซึ่งในที่สุดแล้วระยะทางจะพิสูจน์ม้า กาลเวลาจะเป็นเครื่องพิสูจน์คนเองครับ

แหล่งข้อมูล :
Microsoft Open Source
PORT25 (Communication from The Open Source Software Lab @ Microsoft)
Shared Source Licenses
Sun Java OpenSource

วันพฤหัสบดีที่ ๒ สิงหาคม พ.ศ. ๒๕๕๐

ยุน อึน เฮ ชุด 1 (Yoon Eun Hye 1)

เจอเรื่องเครียดๆ มาทั้งวัน เรามาพักสายตากับดาราคนโปรดของผมกันครับ เธอชื่อ ยุน อึน เฮ เป็นดาราสาวชาวเกาหลีใต้ เคยเป็นนักร้องวง Baby Vox และเคยแสดงเรื่อง เจ้าหญิงวุ่นวายกับเจ้าชายเย็นชา (Goong) ช่วงก่อนผิวขาว แต่หลังๆ มาไปอาบแดดแล้ว (น่าจะปรึกษากันก่อน..) นิสัยน่ารัก เรียบร้อย กล้าแสดงออก



แหล่งข้อมูล :
EunHye Club (Thailand)
The Official BABY V.O.X Community of Thailand

วันพุธที่ ๑ สิงหาคม พ.ศ. ๒๕๕๐

Value Types (2) : User-defined value types

User-defined value types ก็คือ การใช้ Structure ... End Structure แทน Class ... End Class ถ้ามองในอีกมุมนึงก็จะพบว่า Structure คือ keyword ในการทำ encapsulation หรือเป็นการเอา Built-in types มาบรรจุไว้นั้นเอง ซึ่ง Structure แตกต่างจาก Class หลายอย่าง ได้แก่
1. มีการเก็บค่า (allocate) ในหน่วยความจำเป็นแบบ stack
2. ไม่สามารถ inherit ได้
3. ไม่ยืดหยุ่นและมีข้อกำจัดการใช้ event handle
4. จะต้องมี attribute หรือ Property หรือ field อย่างน้อย 1 ตัว

แม้ Structure จะมีข้อด้อยมากกว่า Class แต่จริงๆ แล้ว Structure เกิดมาเพื่อทำงานกับข้อมูลจำนวนไม่มาก นั้นคือ ควรมี instance ของ Structure ขนาดเล็กกว่า 16 bytes (คำนวณคร่าวๆ ได้จากผลรวมของขนาด Attribute หรือ property ของ Structure นั้น) ซึ่งจะทำให้ Structure ทำงานได้เร็ว (performance) กว่า Class

โดย default แล้ว ถ้าไม่เขียน accessibility ใดๆ (Public, Private, Friend, Protected) จะถือว่าเป็น Public และสมาชิกใดๆ ภายใน Structure จะต้องระบุ accessibility กรณีที่ใช้ Dim หรือไม่ระบุกับสมาชิกก็จะถือว่าสมาชิกนั้นเป็น Public

ตัวอย่าง

Public Structure Car
Public CC As UShort
Public Gear As Byte

Public Sub New(ByVal Brand As String)
...
End Sub

Public Sub Break()
...
End Sub
End Structure

แหล่งข้อมูล :
Using Structures in VB.NET - By PrasadGVL.
VB.NET Structure Statement - By Michael McIntyre

มาออกกำลังกายกับ Wii Fit กัน (Exercise with Wii Fit)

ขยับ.. มาขยับเถอะ.. พ่อแม่พี่น้อง..
ขยับ.. มาขยับเถอะ.. ปู่ป้าน้าอา..