From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,243dc2fb696a49cd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews1.google.com!not-for-mail From: slatyb@yahoo.com (K) Newsgroups: comp.lang.ada Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) Date: 2 Oct 2004 00:35:19 -0700 Organization: http://groups.google.com Message-ID: <4c2ec8a8.0410012335.dcf9001@posting.google.com> References: <1700922.2nPlMsa4Ny@linux1.krischik.com> <1636756.M7hCqjsVMv@linux1.krischik.com> <415c36c0$0$91010$39cecf19@news.twtelecom.net> NNTP-Posting-Host: 24.219.97.214 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1096702520 11426 127.0.0.1 (2 Oct 2004 07:35:20 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 2 Oct 2004 07:35:20 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:4553 Date: 2004-10-02T00:35:19-07:00 List-Id: Georg Bauhaus wrote in message news:... > Kevin Cline wrote: > : Not much of a savings over simply writing > : separate create, read, and update functions for the record type. > > Why are you so keen on savings? Because it makes an enormous difference in the cost of developing and maintaining code. It's much easier to write and maintain a table like this: dbmap order_map; order_map.insert("ORDER.NUMBER", &Order::number) .insert("ORDER.CUSTOMER", &Order::customer_number) .insert("ORDER.ACCEPTED", &Order::acceptance_date) .insert("ORDER.PROMISED", &Order::promised_ship_date) ... and then be able to write: Order order; order_map.read(dbreader, order); order.promised_ship_date = ship_date(order.line_items); order_map.update(dbconnection, order); than to maintain code like this: read_order(DatabaseReader& reader, Order& order) { order.number = reader["ORDER.NUMBER"]; order.customer_number = reader["ORDER.CUSTOMER"]; order.acceptance_date = parse(reader["ORDER.ACCEPTED"]); ... } update_order(DatabaseConnection& connection, Order& order) { writer["ORDER.NUMBER"] = order.number; writer["ORDER.CUSTOMER"] = ...; } create_order(...) { // more of the same } Maybe you're happy keeping three copies of essentially the same code carefully synchronized. I'm not. I prefer to squeeze out as much redundancy as possible so that changes need be made in only one place. That is one of the key practices that separates expert programmers from average programmers. The average programmer gets a requirement to add two new fields to a record, and has to carefully update three separate functions. Except that once in a while he misses one and the functions are out of sync, and an hour is lost tracking the problem. The expert simply has to add two members to the record definition, then add two entries to the map, with almost no way to go wrong. Basically, if you know what code is going to say without reading it, then the code is redundant, and should be rewritten to eliminate the redundancy. I have found this to be easier in C++ than in Ada. Admittedly, C++ template programming could be easier. Most programmers would be incapable of writing the dbmap class and the associated infrastructure. But once written, all programmers would be able to use the dbmap class. In a reflective language this sort of mapping is relatively simple and should be within the abilities of most developers.