Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #37181

Re: Using main from abstract class in concrete class

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Cecil Westerhof <Cecil@decebal.nl>
Newsgroups comp.lang.java.programmer
Subject Re: Using main from abstract class in concrete class
Date Sun, 13 Aug 2017 17:17:04 +0200
Organization Decebal Computing
Lines 36
Message-ID <87wp67v6of.fsf@munus.decebal.nl> (permalink)
References <87h8xbx0ig.fsf@munus.decebal.nl> <ompnlf$7j6$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
Injection-Info mx02.eternal-september.org; posting-host="1615173a1409002a85fbdd25ac4b9ead"; logging-data="18040"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18QIkdTSMJuEZ7o+huu/D2T3yMKHgHmP4A="
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
Cancel-Lock sha1:dQeZj+2hsLG70Mxmxrv/qOLJqBQ= sha1:j5AofVRZMAM3chudn5Ber0UJctc=
X-Homepage http://www.decebal.nl/
Xref csiph.com comp.lang.java.programmer:37181

Show key headers only | View raw


Eric Sosman <esosman@comcast-dot-net.invalid> writes:

> However, in this situation I think it'd be simpler for the subclass
> to do its own instantiating and just hand the object to a method of
> the superclass:
>
> 	public abstract class Abstract2 {
> 	    protected static void start(Abstract2 obj, String[] args) {
> 	        // obj is the desired instance
> 	        ...
> 	    }
> 	}
>
> 	class Concrete2 extends Abstract2 {
> 	    public static void main(String[] args) {
> 	        Abstract.start(new Concrete2(), args);
> 	    }
> 	}

I do something like that now:
    public class SQLite3 extends SQL {
        // ################ main
        public static void main(final String[] args) throws SQLException {
            SQL.mainWork(SQLite3.class.getCanonicalName(), args);
        }

The ‘problem’ is that I have to write it for every concrete class, but
that is doable.

I renamed main in the abstract class SQL to mainWork and removed
public.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Using main from abstract class in concrete class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 11:47 +0200
  Re: Using main from abstract class in concrete class Andreas Leitgeb <avl@logic.at> - 2017-08-13 10:59 +0000
    Re: Using main from abstract class in concrete class Andreas Leitgeb <avl@logic.at> - 2017-08-13 11:38 +0000
  Re: Using main from abstract class in concrete class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 15:43 +0200
  Re: Using main from abstract class in concrete class Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-08-13 10:32 -0400
    Re: Using main from abstract class in concrete class Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-08-13 10:37 -0400
    Re: Using main from abstract class in concrete class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 17:17 +0200
      Re: Using main from abstract class in concrete class Andreas Leitgeb <avl@logic.at> - 2017-08-17 18:56 +0000
        Re: Using main from abstract class in concrete class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-18 06:37 +0200
          Re: Using main from abstract class in concrete class Andreas Leitgeb <avl@logic.at> - 2017-08-18 19:48 +0000
            Re: Using main from abstract class in concrete class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-18 23:37 +0200
              Re: Using main from abstract class in concrete class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-19 01:32 +0200
  Re: Using main from abstract class in concrete class Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2017-08-13 12:03 -0500

csiph-web