Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.java.programmer Subject: Re: Where to put the return Date: Sat, 19 Aug 2017 17:15:40 +0200 Organization: Decebal Computing Lines: 63 Message-ID: <87o9rbh9lv.fsf@munus.decebal.nl> References: <87zib6zeup.fsf@munus.decebal.nl> <87y3qlnyvj.fsf@munus.decebal.nl> <87bmnbj09u.fsf@munus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="3820b20d39a2e7728f71dbc5da182e9b"; logging-data="27038"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/SoAHP2+GuIdLqlu6433KRBLRU7EFQACY=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:29a6aKgxZoTjhNWWHnKHd+PiwDo= sha1:Xwjn+bMeiFkV6mv5rzj4fVE5EWc= X-Homepage: http://www.decebal.nl/ Xref: csiph.com comp.lang.java.programmer:37289 Robert Klemme writes: > On 19.08.2017 12:54, Cecil Westerhof wrote: >> Robert Klemme writes: >>> On 15.08.2017 08:12, Cecil Westerhof wrote: > >>>> One of the things I do is make sure you cannot use index. I find that >>>> a very bad habit. >>> >>> Why? >> >> I have to often seen that a database definition changed and there was >> a big problem with the code, because a lot of queries had to be >> changed. > > What does that have to do with accessing via index or name? You are > talking about changing queries because of changed schema. But that does > not necessarily have effects on the layout of the ResultSet. Because I have seen to many cases where coders did something like: SELECT * FROM myTable You could say that when you use all fields that is not a problem, but even then I would not use it. But others do. Also if you use the wrong variable in your getQuery the change you get an error (what you should want) is bigger with a accessing by name as by index. >> I agree that with the kind of programs my wrapper will be used it >> probably is mot a big deal, but it does not hurt to make people learn >> to use better practises. > > Again, why is it a better practice to avoid accessing columns via index > instead of name? See above. >>> Sorted view is another thing I would not do. I am not sure that is even >>> a supported features across most databases. It does have issues - >>> technical and conceptual. >> >> In this case it is on a SQLite3 database which does have it and I >> think it very unlikely to change. But you are right: when I want the >> code to be portable I should not use this, or add a comment to the >> code. > > It's not only about portability. It is also about conceptual issues. A > view is just a view on data. In relational theory, which is the > foundation of RDBMS and SQL, a view is just a special subset of the > data. (But do not make the mistake to reduce SQL to relational theory - > it is actually more.) I removed the ‘ORDER BY’ in my views. It is handy when using a database browser, but not that important. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof