Archive for category Java
Stateless private methods: static or not?
Posted by Alexey in Java, Software Development, Work on Ноябрь 16, 2005
We had an short argument with a collegue at work recently whether the private «stateless» methods of a class (those that do not use instance fields) should be declared static or not. My opinion was they should be static because this marks them as stateless and not only eases code reviews, but provides a compile time safety against using instance fields. This used to help me when I was digging in numerous piles of somebody else’s code. In turn his argument was that
… if someone decides that they need some state in the method it is possible that they’ll make the mistake of creating or changing a static variable instead of creating an instance variable or removing static from the method signature. Also, static methods tend to create yet more static methods, like cancer.
I don’t like declaring all methods as instance methods just because there are people with procedural language background that can’t or don’t want to fight their habits. If the field should be an instance field, don’t make it static, it just won’t work in most cases!
I am eager to hear your opinions on the case.
Things that I still discover about Java
Posted by Alexey in Java, Software Development on Октябрь 18, 2005
Once in a while I find those little tricky things in the core Java that I didn’t know before. Read my Things that I still discover about Java page.
Sun Certified Java Programmer for J2SE 5.0
Продолжая славные традиции Рустама, докладываю, что сегодня успешно сдан экзамен на Sun Certified Java Programmer for J2SE 5.0.
На 63 вопроса из 72х отвечено правильно, то есть 87%. Проходной балл был 59%. Надо сказать, что экзамен был не лёгкий, и, не готовившись, я бы вряд ли его сдал. Во-первых, практического опыта с Java 1.5 у меня очень мало, да и то давно было. Тут мне помог сановский онлайновый курс по отличиям 1.5 от 1.4. Во-вторых, все вопросы подковыристые, и расслабиться они мне не давали. Благо, Рустам подсказал, как найти эмулятор натурального экзамена, так что к подковыристости я был готов.
Красивой бумажки пока нет, ждём.
Запарился искать парковку около Wembley Stadium в Лондоне, навернул два круга, знаки типа «парковка-туда!» везде есть, а самих парковок нет. Нашёл какую-то заброшенную в конце концов, но за 8 фунтов. К тому времени был уже на нервах, и готов был отдать последние трусы за место, так как опаздывал на 10 минут. В следующий раз выеду намного заранее. Если «томтом» говорит ехать 33 минуты, то в Лондоне в час пик это означает час.
Свежие комментарии