かつのりの日記2

わんくまでは珍しいJavaを中心とした日記です

目次

Blog 利用状況

書庫

日記カテゴリ

いろいろリンク

不要なメンバを削除する

元ネタ

http://blogs.wankuma.com/ognac/archive/2007/10/11/101444.aspx

http://blogs.wankuma.com/jeanne/archive/2007/10/11/101389.aspx

Ognacさんのエントリのコメントにも書いたのですが、自分がJavaでやる場合の話です。

メソッドを副作用なしで削除するということですが、自分の場合は事前に設計段階で考慮します。業務アプリでもフレームワークでも同じなのですが、実装クラスは極力隠蔽してインターフェイス経由で利用させます。特にレイヤーを跨ぐ場合は必須です。

例えばレイヤーモデルを採用したWEBアプリの場合、ビュー層、ビジネスロジック層、データアクセス層というようにレイヤーが分かれますが、ビュー層からはビジネスロジック層の実装クラスを直接利用するのではなく、ビジネスロジックインターフェイスを経由して利用します。ビュー層が直接ビジネスロジック層の実装クラスを参照しないようにDIコンテナなどにインジェクションしてもらうのがベストでしょう。

インターフェイスに書かれているメソッドは公開しているものです。ですので利用しているかもしれないという事を考慮して絶対に削除しません。せいぜい@Deprecatedを指定して、「使うな」というのを指示する程度です。インターフェイスに書かれているメソッドは公開している以上、呼び出しても問題ないということを保障しなければなりません。

逆にインターフェイスに書かれているメソッドを保障する分、非インターフェイスのメソッドは例えpublicであっても直接利用することを許してはいけません。そのメソッドが使われていようと、使われていなかろうと、お構いなしで削除してOKとしています。削除されて困るなら直接利用するなという考え方ですね。

ですので、非インターフェイスのメソッドについては認知しているドメイン内で副作用がないと確認できれば、どんどん削除します。逆にインターフェイスのメソッドについては何が何でも維持します。仮に削除したいのであれば、空実装にして@Deprecatedを指定します。

でもこれって極当たり前じゃないかと思っています。JDK自体のコードも大体そんな感じです。

privateなメンバになればEclipseの機能で未使用であると警告を出す事ができます。沢山未使用なものがあれば、Eclipseの場合クリーンコマンドで一括削除する事もできます。未使用なので当然副作用なしで自動削除ができます。

そもそも自分の場合、コードのルールを厳しくして書いているので、最初から未使用コードに対するエラーが出てきます。なので殆どクリーンコマンドで一括削除なんてやったことがないというのが現実ですね。

投稿日時 : 2007年10月12日 1:05

Feedback

# re: 不要なメンバを削除する 2007/10/12 9:53 まさる

なんだかこういうエントリを読んでいると、EclipseってIDEとして非常に優秀なんだなぁと思います。
Visual Studioにもぜひがんばってほしいところ。

# re: 不要なメンバを削除する 2007/10/12 9:54 凪瀬

多プロジェクトと共有していたりするとこのあたりのルール付けが厳格でないと混乱するのでしょうね。
私は今は小さなプロジェクトでやっているので、なあなあな運用になってしまっていますが…。

インターフェースの変更の場合に、古いメソッドをいつまで残しておくべきなのか?
javaの標準APIとかはすでに使っている人がいる可能性を考えると削除することは出来ないのでしょうけども、
独自のものに関しては利用側すべてが確認できるなら変更もありなのかな、と思ってます。
汎用ライブラリになればなるほど難しくなるだろうとは思いますが。

# re: 不要なメンバを削除する 2007/10/12 10:59 kox

そのメソッドが使われていようと、使われていなかろうと、お構いなしで削除してOKとしています。削除されて困るなら直接利用するなという考え方ですね。
僕は絶対に削除しないし、させないですね。
そのときの副作用で運用がとまることの方が怖い。

# I'm not sure why but this website is loading very slow for me. Is anyone else having this issue or is it a issue on my end? I'll check back later on and see if the problem still exists. 2019/05/08 14:59 I'm not sure why but this website is loading very

I'm not sure why but this website is loading very slow
for me. Is anyone else having this issue or is it a
issue on my end? I'll check back later on and see if
the problem still exists.

# It is perfect time to make some plans for the long run and it is time to be happy. I've read this submit and if I could I desire to counsel you some attention-grabbing issues or suggestions. Maybe you could write next articles referring to this article. 2019/05/11 18:50 It is perfect time to make some plans for the long

It is perfect time to make some plans for the long run and it is
time to be happy. I've read this submit and if I could I desire to counsel you
some attention-grabbing issues or suggestions. Maybe you
could write next articles referring to this article.

I desire to read even more issues about it!

# Hi there just wanted to give you a quick heads up and let you know a few of the pictures aren't loading correctly. I'm not sure why but I think its a linking issue. I've tried it in two different browsers and both show the same outcome. 2019/05/12 14:17 Hi there just wanted to give you a quick heads up

Hi there just wanted to give you a quick heads up and let you know a few of the pictures aren't loading correctly.
I'm not sure why but I think its a linking issue. I've tried it in two different browsers and both show the same outcome.

# I used to be suggested this website by means of my cousin. I'm not certain whether or not this publish is written by way of him as nobody else know such specific approximately my problem. You're incredible! Thanks! 2019/06/03 21:16 I used to be suggested this website by means of my

I used to be suggested this website by means of my
cousin. I'm not certain whether or not this publish is written by way
of him as nobody else know such specific approximately my problem.
You're incredible! Thanks!

# My family every time say that I am killing my time here at net, but I know I am getting know-how everyday by reading such pleasant posts. 2019/06/05 9:48 My family every time say that I am killing my time

My family every time say that I am killing my time here at net, but I know
I am getting know-how everyday by reading such pleasant posts.

# Yes! Finally something about plenty of fish dating site. 2019/06/17 19:55 Yes! Finally something about plenty of fish dating

Yes! Finally something about plenty of fish dating
site.

# obviously like your website however you need to take a look at the spelling on several of your posts. A number of them are rife with spelling issues and I find it very troublesome to inform the truth however I'll certainly come again again. 2019/07/15 19:31 obviously like your website however you need to t

obviously like your website however you need to take a look at the spelling on several of your posts.
A number of them are rife with spelling issues and I find it very
troublesome to inform the truth however I'll certainly come again again.

# obviously like your website however you need to take a look at the spelling on several of your posts. A number of them are rife with spelling issues and I find it very troublesome to inform the truth however I'll certainly come again again. 2019/07/15 19:32 obviously like your website however you need to t

obviously like your website however you need to take a look at the spelling on several of your posts.
A number of them are rife with spelling issues and I find it very
troublesome to inform the truth however I'll certainly come again again.

# obviously like your website however you need to take a look at the spelling on several of your posts. A number of them are rife with spelling issues and I find it very troublesome to inform the truth however I'll certainly come again again. 2019/07/15 19:33 obviously like your website however you need to t

obviously like your website however you need to take a look at the spelling on several of your posts.
A number of them are rife with spelling issues and I find it very
troublesome to inform the truth however I'll certainly come again again.

# obviously like your website however you need to take a look at the spelling on several of your posts. A number of them are rife with spelling issues and I find it very troublesome to inform the truth however I'll certainly come again again. 2019/07/15 19:34 obviously like your website however you need to t

obviously like your website however you need to take a look at the spelling on several of your posts.
A number of them are rife with spelling issues and I find it very
troublesome to inform the truth however I'll certainly come again again.

# It's actually a cool and helpful piece of information. I'm satisfied that you simply shared this useful information with us. Please stay us informed like this. Thanks for sharing. 2019/07/18 7:31 It's actually a cool and helpful piece of informat

It's actually a cool and helpful piece of information. I'm satisfied that you simply shared this
useful information with us. Please stay us informed like this.
Thanks for sharing.

# Wow that was odd. I just wrote an incredibly long comment but after I clicked submit my comment didn't show up. Grrrr... well I'm not writing all that over again. Regardless, just wanted to say excellent blog! 2019/07/21 0:55 Wow that was odd. I just wrote an incredibly long

Wow that was odd. I just wrote an incredibly long
comment but after I clicked submit my comment didn't show
up. Grrrr... well I'm not writing all that over again. Regardless, just wanted to say excellent blog!

# First off I would like to say terrific blog! I had a quick question which I'd like to ask if you do not mind. I was interested to know how you center yourself and clear your mind before writing. I've had a hard time clearing my mind in getting my though 2019/07/31 23:31 First off I would like to say terrific blog! I had

First off I would like to say terrific blog! I had a quick question which I'd like to ask if you do not mind.
I was interested to know how you center yourself and clear your mind before writing.
I've had a hard time clearing my mind in getting my thoughts out.

I truly do enjoy writing but it just seems like the first 10 to 15
minutes are generally wasted just trying to figure out how to begin. Any ideas or tips?
Appreciate it!

# First off I would like to say terrific blog! I had a quick question which I'd like to ask if you do not mind. I was interested to know how you center yourself and clear your mind before writing. I've had a hard time clearing my mind in getting my though 2019/07/31 23:32 First off I would like to say terrific blog! I had

First off I would like to say terrific blog! I had a quick question which I'd like to ask if you do not mind.
I was interested to know how you center yourself and clear your mind before writing.
I've had a hard time clearing my mind in getting my thoughts out.

I truly do enjoy writing but it just seems like the first 10 to 15
minutes are generally wasted just trying to figure out how to begin. Any ideas or tips?
Appreciate it!

# First off I would like to say terrific blog! I had a quick question which I'd like to ask if you do not mind. I was interested to know how you center yourself and clear your mind before writing. I've had a hard time clearing my mind in getting my though 2019/07/31 23:33 First off I would like to say terrific blog! I had

First off I would like to say terrific blog! I had a quick question which I'd like to ask if you do not mind.
I was interested to know how you center yourself and clear your mind before writing.
I've had a hard time clearing my mind in getting my thoughts out.

I truly do enjoy writing but it just seems like the first 10 to 15
minutes are generally wasted just trying to figure out how to begin. Any ideas or tips?
Appreciate it!

# First off I would like to say terrific blog! I had a quick question which I'd like to ask if you do not mind. I was interested to know how you center yourself and clear your mind before writing. I've had a hard time clearing my mind in getting my though 2019/07/31 23:34 First off I would like to say terrific blog! I had

First off I would like to say terrific blog! I had a quick question which I'd like to ask if you do not mind.
I was interested to know how you center yourself and clear your mind before writing.
I've had a hard time clearing my mind in getting my thoughts out.

I truly do enjoy writing but it just seems like the first 10 to 15
minutes are generally wasted just trying to figure out how to begin. Any ideas or tips?
Appreciate it!

# Thanks for another informative site. Where else could I am getting that type of info written in such an ideal way? I've a challenge that I am simply now working on, and I've been at the look out for such info. 2019/08/02 9:18 Thanks for another informative site. Where else c

Thanks for another informative site. Where else could I am getting
that type of info written in such an ideal way? I've
a challenge that I am simply now working on, and I've been at
the look out for such info.

# Very good blog you have here but I was curious if you knew of any forums that cover the same topics discussed here? I'd really like to be a part of community where I can get comments from other knowledgeable people that share the same interest. If you h 2019/08/14 7:19 Very good blog you have here but I was curious if

Very good blog you have here but I was curious if you knew of any
forums that cover the same topics discussed here?
I'd really like to be a part of community where I can get
comments from other knowledgeable people that
share the same interest. If you have any recommendations,
please let me know. Thanks a lot!

# Useful info. Fortunate me I found your web site by chance, and I'm shocked why this twist of fate did not happened in advance! I bookmarked it. 2019/08/14 11:34 Useful info. Fortunate me I found your web site b

Useful info. Fortunate me I found your web site by chance, and
I'm shocked why this twist of fate did not happened in advance!
I bookmarked it.

# Hurrah! Finally I got a website from where I can truly get valuable information concerning my study and knowledge. 2019/09/05 19:08 Hurrah! Finally I got a website from where I can t

Hurrah! Finally I got a website from where I can truly get valuable information concerning my study and knowledge.

# re: ??????????? 2021/07/16 18:36 hydroxychloroquine 200 mg twice a day

side effects of chloroquine https://chloroquineorigin.com/# hydroxychloroquine 200mg

# vtvuoyogoejd 2021/12/03 0:14 dwedayryuy

https://hydroaaralen.com/ fda hydroxychloroquine

# krteweozubip 2022/05/20 13:49 djggowbj

erythromycin ophthalmic ointment side effects https://erythromycin1m.com/#

タイトル
名前
Url
コメント