• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interface  RSS feed

 
Prashanth Bhanu
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I've an interface with 4 methods in them.Now one of my class implementing that interface need to implement only two of the methods for the security reasons.
How do i achieve this by using the existing interface and not creating the new interface to serve my purpose.Can any body clarify my doubt.
Thanks in advance
prashu
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you must implement them all, that's the interface contract after all.

There's basically 2 options available to you if you don't want to define another interface (maybe a superinterface to your interface that defines only 2 methods?) and that to either give an implementation that does nothing or give and implementation that throws an exception (usually an UnsupportedOperationException would be a good choice for that).
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But tell us: why don't you want to introduce the second interface?
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've seen teachers and architects (even highly paid highly experienced ones) state bluntly that the number of classes in an application is directly and inversely proportional to the quality of that application.
Therefore they promote bundling as much as possible into each single class or interface in order to cut down on the number of them.

This reasoning is of course blatantly incorrect as a general rule but surprisingly common.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeroen Wenting:
I've seen teachers and architects (even highly paid highly experienced ones) state bluntly that the number of classes in an application is directly and inversely proportional to the quality of that application.
Therefore they promote bundling as much as possible into each single class or interface in order to cut down on the number of them.

This reasoning is of course blatantly incorrect as a general rule but surprisingly common.


Yes, it's actually known as an Anti Pattern: http://c2.com/cgi/wiki?FearOfAddingClasses
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Must come from a COBOL background. We used to be perversely proud of 40,000 line programs. With all the variables and paragraphs named after movie stars. And a set of fields called Date, Dayt, Deight and Dait. Ah, nostalgia, it just ain't what it used to be.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stan James:
And a set of fields called Date, Dayt, Deight and Dait.
ROFLMAO! Thank you for making me spit soda all over my monitor. At least I missed the keyboard.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ah yes, the good old days.
We used to tell everyone who chided us for using Cobol that we were practicing object oriented programming.
After all, everything compiled into objects which were then linked together
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Back in 1996 I was doing mostly PowerBuilder and SQL and etaching myself Java on the side. After completing a large project, my boss told me about the next wave of doing Y2K fixes and said I needed to pick up COBOL ASAP. I always enjoy learning new technologies, and I knew the money would be great.

So I go to Borders and start thumbing through an introductory book on COBOL when I got to this (paraphrasing as I don't remember the #'s):
COBOL programs have strict formatting rules. A line comment must begin in the third column. Labels begin in the first column and execution statements the eighth.
I placed the book back onto the shelf, handed in my resignation letter, and started doing PowerBuilder and Java contract work a couple days later.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I make a point of never saying bad things about COBOL the language. (The code I've seen I can say plenty about.) After it took the committee twenty-some years to invent END-IF it's a pretty darned capable language, ideal for some tasks like computing with money, unmatched in the way it defines data structures, and with about the coolest "case" statement ever. I still like IBM mainframes, too. CICS is a killer TPM and mainframe DB2 rocks.
 
Peter Rooke
Ranch Hand
Posts: 900
7
Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've heard that the COBOL folk had layered architecture, transaction monitors way back (1968) before I was born!

Yes, I suffered COBOL at college. My problem was that I was also working as a C programmer - [IMHO] these two just don't mix.

I worked with a system designed by a COBOL guy, but developed using Powerbuilder. The relational database design wasn�t relational at all, much more like a few huge flat files. Just as I was leaving the company, the database engine started complaining about a table having too many columns [more than 200]. Later on I worked on a [Informix] database system, we had over 1000+ global variables, and most of these were arrays of records.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!