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


Groups > comp.lang.java.programmer > #20377 > unrolled thread

proper use of .java files (layout)

Started byinfinitum3d@hotmail.com
First post2012-12-16 07:38 -0800
Last post2012-12-18 10:35 -0800
Articles 20 on this page of 100 — 15 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  proper use of .java files (layout) infinitum3d@hotmail.com - 2012-12-16 07:38 -0800
    Re: proper use of .java files (layout) Robert Klemme <shortcutter@googlemail.com> - 2012-12-16 16:43 +0100
    Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-16 10:50 -0500
      Re: proper use of .java files (layout) "John B. Matthews" <nospam@nospam.invalid> - 2012-12-16 16:25 -0500
    Re: proper use of .java files (layout) markspace <-@.> - 2012-12-16 08:24 -0800
      Re: proper use of .java files (layout) Lew <lewbloch@gmail.com> - 2012-12-17 10:28 -0800
        Re: proper use of .java files (layout) markspace <-@.> - 2012-12-17 13:17 -0800
          Re: proper use of .java files (layout) Lew <lewbloch@gmail.com> - 2012-12-17 13:51 -0800
          Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-17 20:55 -0500
            Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-17 18:18 -0800
              Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-17 21:28 -0500
                Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-17 21:10 -0800
                  Re: proper use of .java files (layout) Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-18 08:53 -0500
                    Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-18 09:13 -0800
                      Re: proper use of .java files (layout) Patricia Shanahan <pats@acm.org> - 2012-12-18 09:23 -0800
                        Re: proper use of .java files (layout) Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-18 13:49 -0500
                          Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-18 15:05 -0800
                          Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 20:11 -0500
                            Re: proper use of .java files (layout) Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-18 21:07 -0500
                              Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-19 09:33 +0000
                                Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-19 10:12 -0800
                                Re: proper use of .java files (layout) Lew <lewbloch@gmail.com> - 2012-12-19 13:35 -0800
                                Re: proper use of .java files (layout) Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-12-19 15:55 -0600
                                  Re: proper use of .java files (layout) Lew <lewbloch@gmail.com> - 2012-12-19 14:01 -0800
                                    Re: proper use of .java files (layout) Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-12-19 16:05 -0600
                              Re: proper use of .java files (layout) Patricia Shanahan <pats@acm.org> - 2012-12-19 04:06 -0800
                                Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-19 12:24 +0000
                                Re: proper use of .java files (layout) Lew <lewbloch@gmail.com> - 2012-12-19 13:36 -0800
                        Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 20:10 -0500
                      Re: proper use of .java files (layout) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-12-18 12:14 -0600
                  Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 20:04 -0500
                    Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-19 10:14 -0800
                      Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-19 19:18 -0500
                        Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-20 11:05 +0000
                          Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-27 21:43 -0500
                            Re: proper use of .java files (layout) Lew <lewbloch@gmail.com> - 2012-12-27 18:49 -0800
                              Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-27 22:10 -0500
                        Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-20 09:01 -0800
                          Re: proper use of .java files (layout) Patricia Shanahan <pats@acm.org> - 2012-12-20 09:30 -0800
                            Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-20 13:35 -0800
                              Re: proper use of .java files (layout) Patricia Shanahan <pats@acm.org> - 2012-12-20 14:00 -0800
                                Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-21 08:58 +0000
                                  Re: proper use of .java files (layout) Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-12-21 10:36 -0800
                                    Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-21 18:43 +0000
                                  Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-27 22:05 -0500
                                    Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-28 09:57 +0000
                                Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-27 21:59 -0500
                            Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-27 21:53 -0500
                              Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-27 21:54 -0500
                          Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-27 21:48 -0500
                            Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-27 21:11 -0800
                              Re: proper use of .java files (layout) "John B. Matthews" <nospam@nospam.invalid> - 2012-12-28 06:50 -0500
                            Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-28 13:46 +0000
                              Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-28 09:10 -0800
          Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-18 09:50 +0000
            Re: proper use of .java files (layout) "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-12-18 13:09 +0000
              Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-18 14:05 +0000
          Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-25 15:06 -0800
          Re: proper use of .java files (layout) Patricia Shanahan <pats@acm.org> - 2012-12-26 06:31 -0800
            Re: proper use of .java files (layout) Lew <lewbloch@gmail.com> - 2012-12-26 13:21 -0800
              Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-26 23:38 -0500
              Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-27 08:37 +0000
              Re: proper use of .java files (layout) Robert Klemme <shortcutter@googlemail.com> - 2012-12-27 11:51 +0100
                Re: proper use of .java files (layout) Patricia Shanahan <pats@acm.org> - 2012-12-27 08:46 -0800
                  Re: proper use of .java files (layout) Robert Klemme <shortcutter@googlemail.com> - 2012-12-27 18:20 +0100
                Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-27 20:48 -0500
        Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-17 20:58 -0500
          Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-17 18:22 -0800
            Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-17 21:39 -0500
          Re: proper use of .java files (layout) Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-17 21:25 -0500
            Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-17 21:29 -0500
              Re: proper use of .java files (layout) Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-17 21:32 -0500
                Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-17 21:37 -0500
                  Re: proper use of .java files (layout) Wayne <nospam@all.invalid> - 2012-12-18 18:45 -0500
                    Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 20:13 -0500
    Re: proper use of .java files (layout) infinitum3d@hotmail.com - 2012-12-16 09:23 -0800
    Re: proper use of .java files (layout) infinitum3d@hotmail.com - 2012-12-16 21:07 -0800
    Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-17 10:32 +0000
      Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-17 21:03 -0500
        Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-18 09:34 +0000
          Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 20:00 -0500
          Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 20:01 -0500
    Re: proper use of .java files (layout) infinitum3d@hotmail.com - 2012-12-18 06:32 -0800
      Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-18 15:05 +0000
        Re: proper use of .java files (layout) Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-18 11:07 -0500
          Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-18 16:27 +0000
            Re: proper use of .java files (layout) Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-18 11:44 -0500
              Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-18 17:21 +0000
            Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-18 09:21 -0800
              Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-18 17:39 +0000
                Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-18 10:40 -0800
                  Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-18 19:05 +0000
                    Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-18 15:15 -0800
                Re: proper use of .java files (layout) Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-18 14:12 -0500
                  Re: proper use of .java files (layout) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-12-18 19:39 +0000
                    Re: proper use of .java files (layout) Gene Wirchenko <genew@telus.net> - 2012-12-18 15:17 -0800
          Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 20:07 -0500
            Re: proper use of .java files (layout) Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-18 21:11 -0500
              Re: proper use of .java files (layout) Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 22:24 -0500
      Re: proper use of .java files (layout) markspace <-@.> - 2012-12-18 10:35 -0800

Page 4 of 5 — ← Prev page 1 2 3 [4] 5  Next page →


#20714

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-12-26 23:38 -0500
Message-ID<50dbd0e0$0$291$14726298@news.sunsite.dk>
In reply to#20710
On 12/26/2012 4:21 PM, Lew wrote:
> As a fillip, I correlate Java elements to UML differently from (and therefore
> superior to, by my definition :-') some. Java idiomatically, and
> controversially, exposes all attributes as accessor and mutator (getter and
> setter) methods. Some diagram 'getX()' and 'setX()' methods as methods under
> UML. Tsk. They're still attributes - 'get' and 'set' are just conventions
> for expressing their public face. Architecturally, at the level where UML
> can hope to do any good, I diagram them as attributes.

I completely agree.

UML diagrams are to provide overview not duplicate all the details
in the code.

Attributes are important for the overview.

Getters, setters, toString etc. are not important for the overview.

Arne

[toc] | [prev] | [next] | [standalone]


#20720

Fromlipska the kat <lipskathekat@yahoo.co.uk>
Date2012-12-27 08:37 +0000
Message-ID<idGdnXMoXoNClUHNnZ2dnUVZ8h2dnZ2d@bt.com>
In reply to#20710
On 26/12/12 21:21, Lew wrote:
> Patricia Shanahan wrote:
>> Stefan Ram wrote:

[snip]

> You sketch what you can see, try it as quickly as you can get a prototype up
> (hours, not days), and proceed in however fashion you proceed to fill in the
> details.

I think I already said this didn't I ?
Ah well, we got there in the end.

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


#20722

FromRobert Klemme <shortcutter@googlemail.com>
Date2012-12-27 11:51 +0100
Message-ID<ak2nhuF7qjeU1@mid.individual.net>
In reply to#20710
On 26.12.2012 22:21, Lew wrote:

> To describe the elephant from yet another projection, I use a combination
> of intuitive and cognitive models derived from the linguistic space of the
> application domain.
>
> The intuitive portion matches domain-specific language ("TPS Report") with
> a ready-to-hand skill set of noun-verb object metamodels.
>
> "Hmm, a report /has-a/ {title, ...}, /is-a/ {Retrievable, Readable, ...}."
>
> The metamodel is the idea of "/has-a/" and "/is-a/", the notion of objects
> having types, attributes, and behaviors, and the toolbox containing
> polymorphism, assertions and all the panoply of design and programming skills.

I find the CRC card approach quite nice here: those cards also capture 
major aspects without going in too much detail.  I rarely use them 
physically but I use the concept to remind myself of R and C.

> But it was exactly what Patricia describes. If you think structurally, it might
> look like code - but hey, structure's structure however you describe it.

Right.  That's also the reason why I prefer Visio with the free set of 
stencils for UML modeling over any other UML tool (especially those with 
a proper UML model in the background or even roundtrip engineering) 
because I can add visual elements not part of UML standard to help 
getting ideas across.

> As a fillip, I correlate Java elements to UML differently from (and therefore
> superior to, by my definition :-') some. Java idiomatically, and
> controversially, exposes all attributes as accessor and mutator (getter and
> setter) methods. Some diagram 'getX()' and 'setX()' methods as methods under
> UML. Tsk. They're still attributes - 'get' and 'set' are just conventions
> for expressing their public face. Architecturally, at the level where UML
> can hope to do any good, I diagram them as attributes.

Same here.

> I'm not religious about it. If a paycheck is at stake I'll diagram them
> as blueberries if you like.

I'd prefer strawberries - more space to write something. ;-)

Cheers

	robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

[toc] | [prev] | [next] | [standalone]


#20727

FromPatricia Shanahan <pats@acm.org>
Date2012-12-27 08:46 -0800
Message-ID<jMSdnbdvXZvl5kHNnZ2dnUVZ_v6dnZ2d@earthlink.com>
In reply to#20722
On 12/27/2012 2:51 AM, Robert Klemme wrote:
...
> Right.  That's also the reason why I prefer Visio with the free set of
> stencils for UML modeling over any other UML tool (especially those with
> a proper UML model in the background or even roundtrip engineering)
> because I can add visual elements not part of UML standard to help
> getting ideas across.
...

Round trip UML reminds me of a situation I encountered in the early
1970's. We had a manager who insisted that there had to be an up-to-date
flow chart covering the entire code in each application. The
applications were written in NEAT/3 Level 2, an assembly language. There
was a flow chart standard that required a very rigid format, close to
single column.

We did really use flow charts in some situations, but not for whole
applications, and in much more flexible layouts. The whole program
design documents tended to be text describing the data structures,
functions, and main algorithms in a program.

Fortunately, someone had written an application that read the source for
a program, and generated an ASCII flow chart from it. We ran it, bound
the line printer paper in big binders, showed them to the manager, and
stowed them away.

The flow charts were longer than the assembly language code, no more
readable, and contained a proper subset of the information in the code,
including its comments, so they were really useless. They gave no
architectural or design insight. They existed only in order to be able
to say we had a flow chart.

Round trip UML smells of that situation.

Patricia

[toc] | [prev] | [next] | [standalone]


#20728

FromRobert Klemme <shortcutter@googlemail.com>
Date2012-12-27 18:20 +0100
Message-ID<ak3eb0FcsneU1@mid.individual.net>
In reply to#20727
On 27.12.2012 17:46, Patricia Shanahan wrote:

> The flow charts were longer than the assembly language code, no more
> readable, and contained a proper subset of the information in the code,
> including its comments, so they were really useless. They gave no
> architectural or design insight. They existed only in order to be able
> to say we had a flow chart.

Neat! ;-)

> Round trip UML smells of that situation.

Yes.  I believe the reason for that is that diagram != diagram: a 
diagram generated from some input can only apply standard layout rules. 
  But a diagram created by a human will have deliberate layout and a 
human will also likely refrain from putting all classes of a single 
package (or even a complete source tree) in a single diagram.

And in order to update a diagram from source code you always need 
additional data - either the old diagram or some form of meta data which 
describes placement.  For things created in code you would still get 
default placement and a human would have to edit the diagram anyway.

And if the roundtrip tool would also to need to handle renaming of 
entities like classes and interfaces (a common operation during 
refactoring) there would also need to be support from the IDE to record 
these types of changes and update diagrams properly.

Then we still haven't covered how a project with a few thousand classes 
is handled efficiently (not in terms of CPU cycles but in terms of 
diagrams which provide benefit to the reader).

Plenty of years ago I got to evaluate the first version of a roundtrip 
UML tool which supported sequence diagrams (as representations of 
methods).  I create a sequence diagram with two method invocations both 
of which returned String.  The code didn't compile.  It turned out that 
both variables had the same name.  I couldn't believe they did not think 
of that situation when I stumbled across this after five minutes.  Well, 
my company didn't by the tool then. :-)

Kind regards

	robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

[toc] | [prev] | [next] | [standalone]


#20737

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-12-27 20:48 -0500
Message-ID<50dcfa77$0$283$14726298@news.sunsite.dk>
In reply to#20722
On 12/27/2012 5:51 AM, Robert Klemme wrote:
> Right.  That's also the reason why I prefer Visio with the free set of
> stencils for UML modeling over any other UML tool (especially those with
> a proper UML model in the background or even roundtrip engineering)
> because I can add visual elements not part of UML standard to help
> getting ideas across.

UML is actually rather flexible.

It defines stereotypes and do allow for special graphical
representations of those.

And it also allows comments with a given graphical
representation to be used.

Arne

[toc] | [prev] | [next] | [standalone]


#20410

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-12-17 20:58 -0500
Message-ID<50cfcde6$0$288$14726298@news.sunsite.dk>
In reply to#20397
On 12/17/2012 1:28 PM, Lew wrote:
> markspace wrote:
>> You will of course have to make 52 instances of that class.  Do that at
>
> No "of course" about it.
> http://www.hoylegaming.com/rules/showrule.aspx?RuleID=209
>
>> runtime, don't try to make 52 files.
>
> How many cards in a blackjack shoe?
> http://en.wikipedia.org/wiki/Blackjack
>
> If you hard-code certain assumptions, e.g., that there are 52 cards in the deck,
> your program will be unable to model many games.

I would argue that a deck is always 52 cards, but that some
games use more than one deck.

Arne

[toc] | [prev] | [next] | [standalone]


#20414

FromGene Wirchenko <genew@telus.net>
Date2012-12-17 18:22 -0800
Message-ID<ckkvc8dkgji8kvfi4oj96uu83a8ssp90vm@4ax.com>
In reply to#20410
On Mon, 17 Dec 2012 20:58:59 -0500, Arne Vajhøj <arne@vajhoej.dk>
wrote:

>On 12/17/2012 1:28 PM, Lew wrote:

[snip]

>> If you hard-code certain assumptions, e.g., that there are 52 cards in the deck,
>> your program will be unable to model many games.
>
>I would argue that a deck is always 52 cards, but that some
>games use more than one deck.

     Some games do not use all of the deck; some include one or more
jokers.  See the section "Modified Deck" in
 http://boardgamegeek.com/wiki/page/Standard_Deck_Playing_Card_Games
for several examples.

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#20420

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-12-17 21:39 -0500
Message-ID<50cfd75b$0$295$14726298@news.sunsite.dk>
In reply to#20414
On 12/17/2012 9:22 PM, Gene Wirchenko wrote:
> On Mon, 17 Dec 2012 20:58:59 -0500, Arne Vajhøj <arne@vajhoej.dk>
> wrote:
>
>> On 12/17/2012 1:28 PM, Lew wrote:
>
> [snip]
>
>>> If you hard-code certain assumptions, e.g., that there are 52 cards in the deck,
>>> your program will be unable to model many games.
>>
>> I would argue that a deck is always 52 cards, but that some
>> games use more than one deck.
>
>       Some games do not use all of the deck; some include one or more
> jokers.  See the section "Modified Deck" in
>   http://boardgamegeek.com/wiki/page/Standard_Deck_Playing_Card_Games
> for several examples.

Jokers has already been discussed.

I would not change the definition of deck because some
games does not use all cards in a deck.

public interface Game {
     ...
     public List<Card> cardsUsed();
}

Arne

[toc] | [prev] | [next] | [standalone]


#20415

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2012-12-17 21:25 -0500
Message-ID<kaok7h$3pk$1@dont-email.me>
In reply to#20410
On 12/17/2012 8:58 PM, Arne Vajhøj wrote:
> On 12/17/2012 1:28 PM, Lew wrote:
>> markspace wrote:
>>> You will of course have to make 52 instances of that class.  Do that at
>>
>> No "of course" about it.
>> http://www.hoylegaming.com/rules/showrule.aspx?RuleID=209
>>
>>> runtime, don't try to make 52 files.
>>
>> How many cards in a blackjack shoe?
>> http://en.wikipedia.org/wiki/Blackjack
>>
>> If you hard-code certain assumptions, e.g., that there are 52 cards in
>> the deck,
>> your program will be unable to model many games.
>
> I would argue that a deck is always 52 cards, but that some
> games use more than one deck.

     How come a brand-new pack of cards always has fifty-four?

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

[toc] | [prev] | [next] | [standalone]


#20417

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-12-17 21:29 -0500
Message-ID<50cfd500$0$295$14726298@news.sunsite.dk>
In reply to#20415
On 12/17/2012 9:25 PM, Eric Sosman wrote:
> On 12/17/2012 8:58 PM, Arne Vajhøj wrote:
>> On 12/17/2012 1:28 PM, Lew wrote:
>>> markspace wrote:
>>>> You will of course have to make 52 instances of that class.  Do that at
>>>
>>> No "of course" about it.
>>> http://www.hoylegaming.com/rules/showrule.aspx?RuleID=209
>>>
>>>> runtime, don't try to make 52 files.
>>>
>>> How many cards in a blackjack shoe?
>>> http://en.wikipedia.org/wiki/Blackjack
>>>
>>> If you hard-code certain assumptions, e.g., that there are 52 cards in
>>> the deck,
>>> your program will be unable to model many games.
>>
>> I would argue that a deck is always 52 cards, but that some
>> games use more than one deck.
>
>      How come a brand-new pack of cards always has fifty-four?

It does not always.

It comes with 2, 3 or maybe even 4 jokers.

So number of jokers should be a constructor argument, if
it has to be realistic.

Arne

[toc] | [prev] | [next] | [standalone]


#20418

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2012-12-17 21:32 -0500
Message-ID<kaokjc$5be$1@dont-email.me>
In reply to#20417
On 12/17/2012 9:29 PM, Arne Vajhøj wrote:
> On 12/17/2012 9:25 PM, Eric Sosman wrote:
>> On 12/17/2012 8:58 PM, Arne Vajhøj wrote:
>>>
>>> I would argue that a deck is always 52 cards, but that some
>>> games use more than one deck.
>>
>>      How come a brand-new pack of cards always has fifty-four?
>
> It does not always.
>
> It comes with 2, 3 or maybe even 4 jokers.
>
> So number of jokers should be a constructor argument, if
> it has to be realistic.

     Can we say, then, that "a deck is always 52 cards, for
suitable values of 52?"

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

[toc] | [prev] | [next] | [standalone]


#20419

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-12-17 21:37 -0500
Message-ID<50cfd6d2$0$295$14726298@news.sunsite.dk>
In reply to#20418
On 12/17/2012 9:32 PM, Eric Sosman wrote:
> On 12/17/2012 9:29 PM, Arne Vajhøj wrote:
>> On 12/17/2012 9:25 PM, Eric Sosman wrote:
>>> On 12/17/2012 8:58 PM, Arne Vajhøj wrote:
>>>>
>>>> I would argue that a deck is always 52 cards, but that some
>>>> games use more than one deck.
>>>
>>>      How come a brand-new pack of cards always has fifty-four?
>>
>> It does not always.
>>
>> It comes with 2, 3 or maybe even 4 jokers.
>>
>> So number of jokers should be a constructor argument, if
>> it has to be realistic.
>
>      Can we say, then, that "a deck is always 52 cards, for
> suitable values of 52?"

Very funny.

A deck is 52 + number of jokers cards.

A game may be multiple decks or maybe even a subset of a deck.

Arne

[toc] | [prev] | [next] | [standalone]


#20487

FromWayne <nospam@all.invalid>
Date2012-12-18 18:45 -0500
Message-ID<50d10029$0$17060$9a6e19ea@unlimited.newshosting.com>
In reply to#20419
On 12/17/2012 9:37 PM, Arne Vajhøj wrote:
> On 12/17/2012 9:32 PM, Eric Sosman wrote:
>> On 12/17/2012 9:29 PM, Arne Vajhøj wrote:
>>> On 12/17/2012 9:25 PM, Eric Sosman wrote:
>>>> On 12/17/2012 8:58 PM, Arne Vajhøj wrote:
>>>>>
>>>>> I would argue that a deck is always 52 cards, but that some
>>>>> games use more than one deck.
>>>>
>>>>      How come a brand-new pack of cards always has fifty-four?
>>>
>>> It does not always.
>>>
>>> It comes with 2, 3 or maybe even 4 jokers.
>>>
>>> So number of jokers should be a constructor argument, if
>>> it has to be realistic.
>>
>>      Can we say, then, that "a deck is always 52 cards, for
>> suitable values of 52?"
> 
> Very funny.
> 
> A deck is 52 + number of jokers cards.
> 
> A game may be multiple decks or maybe even a subset of a deck.
> 
> Arne
> 
> 

That's only for a bridge/poker deck.  A pinochle deck consists of two copies
of each of the 9, 10, jack, queen, king, and ace cards of all four suits,
for 48 cards per deck. Aces are always considered high. Pinochle follows a
nonstandard card ordering. The complete ordering from highest to lowest
is A, 10, K, Q, J, 9.  [quoted from Wikipedia]

Trying to generalize all card games with a single abstraction is probably a mistake.
If you limit the card games to those with hands that use a bridge/poker deck,
you probably want a unique ID for each card.  Then the game class should implement
a handValue(Set<Card>) method, which may return a set of HandValues (rather
than a single value; it depends on the game I suppose).  The
implementation can map Cards to value(s) in a given game context.  The
error seems to be trying to put the valuation logic in the Card enum; the
values don't seem to be static enough to me.

-- 
Wayne

[toc] | [prev] | [next] | [standalone]


#20495

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-12-18 20:13 -0500
Message-ID<50d114bd$0$290$14726298@news.sunsite.dk>
In reply to#20487
On 12/18/2012 6:45 PM, Wayne wrote:
> On 12/17/2012 9:37 PM, Arne Vajhøj wrote:
>> On 12/17/2012 9:32 PM, Eric Sosman wrote:
>>> On 12/17/2012 9:29 PM, Arne Vajhøj wrote:
>>>> On 12/17/2012 9:25 PM, Eric Sosman wrote:
>>>>> On 12/17/2012 8:58 PM, Arne Vajhøj wrote:
>>>>>>
>>>>>> I would argue that a deck is always 52 cards, but that some
>>>>>> games use more than one deck.
>>>>>
>>>>>       How come a brand-new pack of cards always has fifty-four?
>>>>
>>>> It does not always.
>>>>
>>>> It comes with 2, 3 or maybe even 4 jokers.
>>>>
>>>> So number of jokers should be a constructor argument, if
>>>> it has to be realistic.
>>>
>>>       Can we say, then, that "a deck is always 52 cards, for
>>> suitable values of 52?"
>>
>> Very funny.
>>
>> A deck is 52 + number of jokers cards.
>>
>> A game may be multiple decks or maybe even a subset of a deck.
>
> That's only for a bridge/poker deck.  A pinochle deck consists of two copies
> of each of the 9, 10, jack, queen, king, and ace cards of all four suits,
> for 48 cards per deck. Aces are always considered high. Pinochle follows a
> nonstandard card ordering. The complete ordering from highest to lowest
> is A, 10, K, Q, J, 9.  [quoted from Wikipedia]
>
> Trying to generalize all card games with a single abstraction is probably a mistake.

Sounds right.

> If you limit the card games to those with hands that use a bridge/poker deck,
> you probably want a unique ID for each card.  Then the game class should implement
> a handValue(Set<Card>) method, which may return a set of HandValues (rather
> than a single value; it depends on the game I suppose).  The
> implementation can map Cards to value(s) in a given game context.  The
> error seems to be trying to put the valuation logic in the Card enum; the
> values don't seem to be static enough to me.

Having game specific values does not preclude having a
natural order.

Arne

[toc] | [prev] | [next] | [standalone]


#20383

Frominfinitum3d@hotmail.com
Date2012-12-16 09:23 -0800
Message-ID<03310662-1eee-47dd-bbde-e5a8f28c042c@googlegroups.com>
In reply to#20377
Brilliant!  That makes perfect sense.

Thank you all for the advice. This will really make things easier for me.

-I3D

[toc] | [prev] | [next] | [standalone]


#20391

Frominfinitum3d@hotmail.com
Date2012-12-16 21:07 -0800
Message-ID<07752240-9783-48b6-9bba-14c78c678c91@googlegroups.com>
In reply to#20377
Thank you John. I'll look into it :)

I3D

[toc] | [prev] | [next] | [standalone]


#20394

Fromlipska the kat <lipskathekat@yahoo.co.uk>
Date2012-12-17 10:32 +0000
Message-ID<TpWdnY_kYZghaVPNnZ2dnUVZ7rSdnZ2d@bt.com>
In reply to#20377
On 16/12/12 15:38, infinitum3d@hotmail.com wrote:
> I'm trying to figure out the best way to layout a java program. Should I put each object into its own .java file? If I'm making a card game, that would be 52 .java files. Is that crazy? Normal?
>
> Or should I separate them by suit and just have 4 .java files? Or by value so there are 13 .java files?
>
> Thanks!
>
> I3D

Here is a possible outline for a simple card game component
It has NOT been compiled.

Comments welcome

Card.java

public class Card{
    //enumeration types for rank and suit perhaps
    ...
}

==========================

Deck.java

public class Deck{

    private Card[] deck = null; //implementation hidden from clients

    public Deck(Integer cardCount){
       deck = new Card[cardCount]; //not all games use all the cards
    }
    ...
}

=========================

Dealer.java

public class Dealer{

    private Deck deck = null;

    public Dealer(Deck deck){
       this.deck = deck;
    }

    public void shuffle(){
       ... //delegate to deck ?
    }
    ...

    public List<Card[]> deal(Integer hands, Integer cardsPerHand){
       ...	
    }
}

===========================

Snap.java

public class Snap {

    private Deck deck = null;
    private Dealer dealer = null;

    public Snap(){
       this.deck = new Deck(54); // don't forget the jokers
       this.dealer = new Dealer(deck);
    }

    public void play(Integer numPlayers){
       dealer.shuffle();
       dealer.deal(numPlayers, 0); // 0 indicates deal all to players
       ...
    }
    ...
}

Java is well suited to an 'Object Oriented' approach to software design
The above outline is just one of many possible OO solutions.

Hope this helps

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


#20411

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-12-17 21:03 -0500
Message-ID<50cfcef0$0$288$14726298@news.sunsite.dk>
In reply to#20394
On 12/17/2012 5:32 AM, lipska the kat wrote:
> Here is a possible outline for a simple card game component
> It has NOT been compiled.

And it will not.

... is not valid Java (in the context where it is used).

> Comments welcome
>
> Card.java
>
> public class Card{
>     //enumeration types for rank and suit perhaps
>     ...
> }
>
> ==========================
>
> Deck.java
>
> public class Deck{
>
>     private Card[] deck = null; //implementation hidden from clients
>
>     public Deck(Integer cardCount){
>        deck = new Card[cardCount]; //not all games use all the cards
>     }
>     ...
> }
>
> =========================
>
> Dealer.java
>
> public class Dealer{
>
>     private Deck deck = null;
>
>     public Dealer(Deck deck){
>        this.deck = deck;
>     }
>
>     public void shuffle(){
>        ... //delegate to deck ?
>     }
>     ...
>
>     public List<Card[]> deal(Integer hands, Integer cardsPerHand){
>        ...
>     }
> }
>
> ===========================
>
> Snap.java
>
> public class Snap {
>
>     private Deck deck = null;
>     private Dealer dealer = null;
>
>     public Snap(){
>        this.deck = new Deck(54); // don't forget the jokers
>        this.dealer = new Dealer(deck);
>     }
>
>     public void play(Integer numPlayers){
>        dealer.shuffle();
>        dealer.deal(numPlayers, 0); // 0 indicates deal all to players
>        ...
>     }
>     ...
> }
>
> Java is well suited to an 'Object Oriented' approach to software design
> The above outline is just one of many possible OO solutions.


A Deck constructor with just the number of jokers would make
more sense to me.

The Deck(cardCount) does not specify what cards are there. And
it is not really a deck but a deck with something added or
removed.

Arne

[toc] | [prev] | [next] | [standalone]


#20433

Fromlipska the kat <lipskathekat@yahoo.co.uk>
Date2012-12-18 09:34 +0000
Message-ID<9fGdnWi_P6sKpU3NnZ2dnUVZ8hadnZ2d@bt.com>
In reply to#20411
On 18/12/12 02:03, Arne Vajhøj wrote:
> On 12/17/2012 5:32 AM, lipska the kat wrote:
>> Here is a possible outline for a simple card game component
>> It has NOT been compiled.
>
> And it will not.

Really, well thank you for pointing that out

[snip]

>> Java is well suited to an 'Object Oriented' approach to software design
>> The above outline is just one of many possible OO solutions.
>
>
> A Deck constructor with just the number of jokers would make
> more sense to me.

Like I said, it was just an outline.

In my house we play games that use a subset of a complete deck, 
sometimes we play a game that uses only the lower ranks of several packs 
of cards

A Pack of cards contains 54 cards including two jokers.
a Deck of cards contains the cards required to play a game, not the same 
thing at all ... hey look, we're already starting to come up with some 
new classes, cool huh.

These type of questions/issues would come out in the wash. You need a 
place to start, often the final result looks nothing like the first 
iteration. Object Oriented software engineering is an iterative process. 
More that that it is a state of mind.

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


Page 4 of 5 — ← Prev page 1 2 3 [4] 5  Next page →

Back to top | Article view | comp.lang.java.programmer


csiph-web