This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-03-24 17:56:57

benjamindragonpants
Scratcher
Registered: 2011-03-03
Posts: 78

Methods and Classes like in Java

Recently, i have been learning Java programming and there was one feature that I thought would be VERY helpful when doing collabs.
Scratch needs something like the way .class files communicate with each other.

For those of you who don't know, java is more advanced programming language. Minecraft is made in java and I believe scratch is too, but i might be wrong. It is made up of .class files, each containing more lines of code. The way they "talk" to each other is by referencing methods, which are the different lines of code within each .class (think of methods like jelly beans. You have the red ones, the blue ones and the yellow ones. Each one tastes differently.) You would reference a method, and the .class it was in would be opened and the method carried out.

Are you still confused about methods and .class files?
Imagine this:
You are a principal at a elementary school. You are the main method, the one that it starts with. You are doing a study on kids lunches. You go to the 3rd graders (they the a .class file) and you pull out Jimmy (Jimmy is your method). Jimmy tells you what he likes to eat for lunch.

How is this handy? Why not just write it all in one line of code?
Well, two reasons. One: If you wrote all of this in one line of code it would get hard to find the lines you needed and
Two: Imagine you are at a professional company (like Apple). You and Bob (your co-worker) are working on a program. You can write one part of the code while Bob writes the other, at the same time.

Ok, how would this work in scratch?
My idea is that if a project was in the same gallery, it could say
Take (spritename) from (projectname)

I think that would help collab projects allot.

Offline

 

#2 2013-03-24 18:31:47

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Methods and Classes like in Java

While this would help kids learn more complicated languages, it would be WAY too complicated to implement in a language designed for people who have no experience with programming whatsoever. Also, it just doesn't fit in Scratch's model.


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#3 2013-03-24 18:54:16

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: Methods and Classes like in Java

i definitely like the idea of classes and think it would be a much better way to go about the idea of cloning, but i'm not really sure how they would implement that well.


Posts: 20000 - Show all posts

Offline

 

#4 2013-03-24 19:44:51

benjamindragonpants
Scratcher
Registered: 2011-03-03
Posts: 78

Re: Methods and Classes like in Java

jvvg wrote:

While this would help kids learn more complicated languages, it would be WAY too complicated to implement in a language designed for people who have no experience with programming whatsoever. Also, it just doesn't fit in Scratch's model.

I think I may have overcomplicated this. It is simply a way to bring sprites and scripts across projects. Please explain how this does not fit scratches model.

Offline

 

#5 2013-03-24 19:50:35

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Methods and Classes like in Java

benjamindragonpants wrote:

jvvg wrote:

While this would help kids learn more complicated languages, it would be WAY too complicated to implement in a language designed for people who have no experience with programming whatsoever. Also, it just doesn't fit in Scratch's model.

I think I may have overcomplicated this. It is simply a way to bring sprites and scripts across projects. Please explain how this does not fit scratches model.

I think I misread the original post.
After re-reading it, I kind of like this idea.


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#6 2013-03-24 20:28:00

KrIsMa
Scratcher
Registered: 2011-09-20
Posts: 500+

Re: Methods and Classes like in Java

benjamindragonpants wrote:

Recently, i have been learning Java programming and there was one feature that I thought would be VERY helpful when doing collabs.
Scratch needs something like the way .class files communicate with each other.

For those of you who don't know, java is more advanced programming language. Minecraft is made in java and I believe scratch is too, but i might be wrong. It is made up of .class files, each containing more lines of code. The way they "talk" to each other is by referencing methods, which are the different lines of code within each .class (think of methods like jelly beans. You have the red ones, the blue ones and the yellow ones. Each one tastes differently.) You would reference a method, and the .class it was in would be opened and the method carried out.

Are you still confused about methods and .class files?
Imagine this:
You are a principal at a elementary school. You are the main method, the one that it starts with. You are doing a study on kids lunches. You go to the 3rd graders (they the a .class file) and you pull out Jimmy (Jimmy is your method). Jimmy tells you what he likes to eat for lunch.

How is this handy? Why not just write it all in one line of code?
Well, two reasons. One: If you wrote all of this in one line of code it would get hard to find the lines you needed and
Two: Imagine you are at a professional company (like Apple). You and Bob (your co-worker) are working on a program. You can write one part of the code while Bob writes the other, at the same time.

Ok, how would this work in scratch?
My idea is that if a project was in the same gallery, it could say
Take (spritename) from (projectname)

I think that would help collab projects allot.

... add id tags too!


http://blocks.scratchr.org/API.php?user=KrIsMa&action=onlineStatus&online=http://i49.tinypic.com/2pzic0m.png&offline=http://i49.tinypic.com/r7p10n.png
The Scratch Team (and fellow scratchers!) is/are so nice!!!

Offline

 

#7 2013-03-25 12:41:33

shadowmouse
New Scratcher
Registered: 2013-02-03
Posts: 100+

Re: Methods and Classes like in Java

benjamindragonpants wrote:

Recently, i have been learning Java programming and there was one feature that I thought would be VERY helpful when doing collabs.
Scratch needs something like the way .class files communicate with each other.

For those of you who don't know, java is more advanced programming language. Minecraft is made in java and I believe scratch is too, but i might be wrong. It is made up of .class files, each containing more lines of code. The way they "talk" to each other is by referencing methods, which are the different lines of code within each .class (think of methods like jelly beans. You have the red ones, the blue ones and the yellow ones. Each one tastes differently.) You would reference a method, and the .class it was in would be opened and the method carried out.

Are you still confused about methods and .class files?
Imagine this:
You are a principal at a elementary school. You are the main method, the one that it starts with. You are doing a study on kids lunches. You go to the 3rd graders (they the a .class file) and you pull out Jimmy (Jimmy is your method). Jimmy tells you what he likes to eat for lunch.

How is this handy? Why not just write it all in one line of code?
Well, two reasons. One: If you wrote all of this in one line of code it would get hard to find the lines you needed and
Two: Imagine you are at a professional company (like Apple). You and Bob (your co-worker) are working on a program. You can write one part of the code while Bob writes the other, at the same time.

Ok, how would this work in scratch?
My idea is that if a project was in the same gallery, it could say
Take (spritename) from (projectname)

I think that would help collab projects allot.

Sounds good, but one small point. Scratch isn't written in Java. I know it's not an important point but say someone wanted to mod scratch and read this then they might go and learn java specifically for modding and have wasted their time.

Offline

 

#8 2013-03-25 12:44:06

firedrake969_test
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: Methods and Classes like in Java

Ask yourself:  "Would a 7-year-old understand this?"  If not, no.

Scratch is targeted toward people who have no sense of programming at all.  If it's too complicated, it's not going to be added.


Alt of Firedrake969.

Offline

 

#9 2013-03-25 19:14:39

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Methods and Classes like in Java

firedrake969_test wrote:

Ask yourself:  "Would a 7-year-old understand this?"  If not, no.

Scratch is targeted toward people who have no sense of programming at all.  If it's too complicated, it's not going to be added.

I don't see what's so hard about getting a sprite from another project...

Offline

 

#10 2013-03-26 10:22:04

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Methods and Classes like in Java

benjamindragonpants wrote:

Recently, i have been learning Java programming and there was one feature that I thought would be VERY helpful when doing collabs.
Scratch needs something like the way .class files communicate with each other.
This is a kid's language. This could be way complicated.

For those of you who don't know, java is more advanced programming language. Minecraft is made in java and I believe scratch is too, but i might be wrong You are, it's made of Flash and Squeak. It is made up of .class files, each containing more lines of code. The way they "talk" to each other is by referencing methods, which are the different lines of code within each .class (think of methods like jelly beans. You have the red ones, the blue ones and the yellow ones. Each one tastes differently.) You would reference a method, and the .class it was in would be opened and the method carried out.

Are you still confused about methods and .class files?
Imagine this:
You are a principal at a elementary school. You are the main method, the one that it starts with. You are doing a study on kids lunches. You go to the 3rd graders (they the a .class file) and you pull out Jimmy (Jimmy is your method). Jimmy tells you what he likes to eat for lunch. Good analogy

How is this handy? Why not just write it all in one line of code?
Well, two reasons. One: If you wrote all of this in one line of code it would get hard to find the lines you needed and
Two: Imagine you are at a professional company (like Apple). You and Bob (your co-worker) are working on a program. You can write one part of the code while Bob writes the other, at the same time. ...since when does Apple use Scratch? They would use Objective-C, which has classes, I believe...

Ok, how would this work in scratch?
My idea is that if a project was in the same gallery, it could say
Take (spritename) from (projectname)

I think that would help collab projects allot. It would, but it's still too complicated. Maybe in BYOB sometime.


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#11 2013-03-26 19:39:01

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: Methods and Classes like in Java

You could already implement a rough prototype oriented programming paradigm using the clone blocks.

Instance methods could be implemented by expanding the concept broadcasting through "personal broadcasts". It could be called "telling" (can't come up with anything better):

when gf clicked
[tell [Sprite v]: [message v]]

when I'm told [message v]
[say [Hi!]]

Easy to understand, and useful though as you all may know by now, there's many workarounds for this.


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#12 2013-03-30 18:17:41

machinespray
Scratcher
Registered: 2012-05-09
Posts: 93

Re: Methods and Classes like in Java

Would this help or am I on the wrong page?

Code:

'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 30 March 2013 at 6:15:42 pm'!

!ScratchFrameMorph methodsFor: 'menu/button actions' stamp: 'BC 3/30/2013 18:13'!
fileMenu: aMenuTitleMorph

    | menu |
    menu _ CustomMenu new.
    menu add: 'New' action: #newScratchProject.
    menu add: 'Open' action: #openScratchProject.
    menu add: 'Save' action: #saveScratchProjectNoDialog.
    menu add: 'Save As' action: #saveScratchProject.
    menu addLine.
    menu add: 'Export Class' action: #class.
    menu add: 'Import Class' action: #importScratchProject.
    menu add: 'Export Sprite' action: #exportSprite.
    menu addLine.
    menu add: 'Project Notes' action: #editNotes.

    Sensor shiftPressed ifTrue: [  "developer menu"
        menu addLine.
        menu add: 'Write Project Summary' action: #writeSummaryFile.
        menu add: 'Write Multiple Project Summaries' action: #writeMultipleSummaries.
        menu addLine.
        fillScreenFlag
            ifTrue: [
                menu add: 'Exit User Mode' action: #fillScreenOff]
            ifFalse: [
                menu add: 'Enter User Mode' action: #fillScreenOn.
                menu add: 'Save Image in User Mode' action: #saveImageForEndUser]].

    menu addLine.
    menu add: 'Quit' action: #quitScratch.
    menu localize.
    
    #(2 4 5 6 7) do: [:n |
        menu labels at: n put:
            ((menu labels at: n) copyFrom: 1 to: (menu labels at: n) size - 1), ScratchTranslator ellipsesSuffix].

    menu invokeOn: self at: aMenuTitleMorph bottomLeft + (0@10).

! !

!ScratchFrameMorph methodsFor: 'file read/write' stamp: 'BC 3/30/2013 18:14'!
class
    | fName result |
    self closeMediaEditorsAndDialogs ifFalse: [^ self].
    self stopAll.

    fName _ ScratchFileChooserDialog saveScratchFileFor: self.
    (fName size = 0 or: [fName = #cancelled]) ifTrue: [^ self].

    [(result _ ScratchFileChooserDialog confirmFileOverwriteIfExisting: fName) = false] whileTrue: [
        fName _ ScratchFileChooserDialog saveScratchFileFor: self.
        (fName size = 0 or: [fName = #cancelled]) ifTrue: [^ self]].
    (result = #cancelled) ifTrue: [^ self].

    self updateLastHistoryEntryIfNeeded.

    fName _ (self nameFromFileName: fName), '.class'.
    projectDirectory _ FileDirectory on: (FileDirectory dirPathFor: fName).
    projectName _ FileDirectory localNameFor: fName.

    projectInfo at: 'author' put: author.
    self updateHistoryProjectName: projectName op: 'save'.
    self writeScratchProject.
! !

!ScratchFrameMorph methodsFor: 'file read/write' stamp: 'BC 3/30/2013 18:15'!
importScratchProject
    "Allow the user to select a project to open, then merge that project's sprites with the
current project."

    | response |
    self closeMediaEditorsAndDialogs ifFalse: [^ self].
    self stopAll.

    response _ ScratchFileChooserDialog
        chooseExistingFileType: #project
        extensions: #(.class)
        title: 'Import Class'.
    response ifNil: [^ self].

    self importSpriteOrProject: response.
! !

I am made a mod for Scratch. If you have any ideas for the mod please post it on this forum page.http://scratch.mit.edu/forums/viewtopic.php?id=108265http://internetometer.com/image/38591.png
I am http://blocks.scratchr.org/API.php?action=onlineStatus&type=text&user=machinespray

Offline

 

#13 2013-03-31 00:15:00

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Methods and Classes like in Java

machinespray wrote:

Would this help or am I on the wrong page?

Code:

'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 30 March 2013 at 6:15:42 pm'!

!ScratchFrameMorph methodsFor: 'menu/button actions' stamp: 'BC 3/30/2013 18:13'!
fileMenu: aMenuTitleMorph

    | menu |
    menu _ CustomMenu new.
    menu add: 'New' action: #newScratchProject.
    menu add: 'Open' action: #openScratchProject.
    menu add: 'Save' action: #saveScratchProjectNoDialog.
    menu add: 'Save As' action: #saveScratchProject.
    menu addLine.
    menu add: 'Export Class' action: #class.
    menu add: 'Import Class' action: #importScratchProject.
    menu add: 'Export Sprite' action: #exportSprite.
    menu addLine.
    menu add: 'Project Notes' action: #editNotes.

    Sensor shiftPressed ifTrue: [  "developer menu"
        menu addLine.
        menu add: 'Write Project Summary' action: #writeSummaryFile.
        menu add: 'Write Multiple Project Summaries' action: #writeMultipleSummaries.
        menu addLine.
        fillScreenFlag
            ifTrue: [
                menu add: 'Exit User Mode' action: #fillScreenOff]
            ifFalse: [
                menu add: 'Enter User Mode' action: #fillScreenOn.
                menu add: 'Save Image in User Mode' action: #saveImageForEndUser]].

    menu addLine.
    menu add: 'Quit' action: #quitScratch.
    menu localize.
    
    #(2 4 5 6 7) do: [:n |
        menu labels at: n put:
            ((menu labels at: n) copyFrom: 1 to: (menu labels at: n) size - 1), ScratchTranslator ellipsesSuffix].

    menu invokeOn: self at: aMenuTitleMorph bottomLeft + (0@10).

! !

!ScratchFrameMorph methodsFor: 'file read/write' stamp: 'BC 3/30/2013 18:14'!
class
    | fName result |
    self closeMediaEditorsAndDialogs ifFalse: [^ self].
    self stopAll.

    fName _ ScratchFileChooserDialog saveScratchFileFor: self.
    (fName size = 0 or: [fName = #cancelled]) ifTrue: [^ self].

    [(result _ ScratchFileChooserDialog confirmFileOverwriteIfExisting: fName) = false] whileTrue: [
        fName _ ScratchFileChooserDialog saveScratchFileFor: self.
        (fName size = 0 or: [fName = #cancelled]) ifTrue: [^ self]].
    (result = #cancelled) ifTrue: [^ self].

    self updateLastHistoryEntryIfNeeded.

    fName _ (self nameFromFileName: fName), '.class'.
    projectDirectory _ FileDirectory on: (FileDirectory dirPathFor: fName).
    projectName _ FileDirectory localNameFor: fName.

    projectInfo at: 'author' put: author.
    self updateHistoryProjectName: projectName op: 'save'.
    self writeScratchProject.
! !

!ScratchFrameMorph methodsFor: 'file read/write' stamp: 'BC 3/30/2013 18:15'!
importScratchProject
    "Allow the user to select a project to open, then merge that project's sprites with the
current project."

    | response |
    self closeMediaEditorsAndDialogs ifFalse: [^ self].
    self stopAll.

    response _ ScratchFileChooserDialog
        chooseExistingFileType: #project
        extensions: #(.class)
        title: 'Import Class'.
    response ifNil: [^ self].

    self importSpriteOrProject: response.
! !

I'm pretty sure you're on the wrong page.

Offline

 

#14 2013-03-31 01:00:55

joshuaho
Scratcher
Registered: 2012-08-20
Posts: 100+

Re: Methods and Classes like in Java

jvvg wrote:

While this would help kids learn more complicated languages, it would be WAY too complicated to implement in a language designed for people who have no experience with programming whatsoever. Also, it just doesn't fit in Scratch's model.

Hey, my friend is young and he knows java!


Did you know that you can go to space and see Mars by clicking here?

Offline

 

#15 2013-03-31 02:20:29

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Methods and Classes like in Java

joshuaho wrote:

jvvg wrote:

While this would help kids learn more complicated languages, it would be WAY too complicated to implement in a language designed for people who have no experience with programming whatsoever. Also, it just doesn't fit in Scratch's model.

Hey, my friend is young and he knows java!

But kids learning programming using Scratch most likely don't.

Offline

 

#16 2013-03-31 16:47:27

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Methods and Classes like in Java

kayybee wrote:

joshuaho wrote:

jvvg wrote:

While this would help kids learn more complicated languages, it would be WAY too complicated to implement in a language designed for people who have no experience with programming whatsoever. Also, it just doesn't fit in Scratch's model.

Hey, my friend is young and he knows java!

But kids learning programming using Scratch most likely don't.

Yeah
I started learning Java (but switched to PHP) AFTER learning Scratch


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#17 2013-04-01 08:23:56

machinespray
Scratcher
Registered: 2012-05-09
Posts: 93

Re: Methods and Classes like in Java

kayybee wrote:

machinespray wrote:

Would this help or am I on the wrong page?

Code:

'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 30 March 2013 at 6:15:42 pm'!

!ScratchFrameMorph methodsFor: 'menu/button actions' stamp: 'BC 3/30/2013 18:13'!
fileMenu: aMenuTitleMorph

    | menu |
    menu _ CustomMenu new.
    menu add: 'New' action: #newScratchProject.
    menu add: 'Open' action: #openScratchProject.
    menu add: 'Save' action: #saveScratchProjectNoDialog.
    menu add: 'Save As' action: #saveScratchProject.
    menu addLine.
    menu add: 'Export Class' action: #class.
    menu add: 'Import Class' action: #importScratchProject.
    menu add: 'Export Sprite' action: #exportSprite.
    menu addLine.
    menu add: 'Project Notes' action: #editNotes.

    Sensor shiftPressed ifTrue: [  "developer menu"
        menu addLine.
        menu add: 'Write Project Summary' action: #writeSummaryFile.
        menu add: 'Write Multiple Project Summaries' action: #writeMultipleSummaries.
        menu addLine.
        fillScreenFlag
            ifTrue: [
                menu add: 'Exit User Mode' action: #fillScreenOff]
            ifFalse: [
                menu add: 'Enter User Mode' action: #fillScreenOn.
                menu add: 'Save Image in User Mode' action: #saveImageForEndUser]].

    menu addLine.
    menu add: 'Quit' action: #quitScratch.
    menu localize.
    
    #(2 4 5 6 7) do: [:n |
        menu labels at: n put:
            ((menu labels at: n) copyFrom: 1 to: (menu labels at: n) size - 1), ScratchTranslator ellipsesSuffix].

    menu invokeOn: self at: aMenuTitleMorph bottomLeft + (0@10).

! !

!ScratchFrameMorph methodsFor: 'file read/write' stamp: 'BC 3/30/2013 18:14'!
class
    | fName result |
    self closeMediaEditorsAndDialogs ifFalse: [^ self].
    self stopAll.

    fName _ ScratchFileChooserDialog saveScratchFileFor: self.
    (fName size = 0 or: [fName = #cancelled]) ifTrue: [^ self].

    [(result _ ScratchFileChooserDialog confirmFileOverwriteIfExisting: fName) = false] whileTrue: [
        fName _ ScratchFileChooserDialog saveScratchFileFor: self.
        (fName size = 0 or: [fName = #cancelled]) ifTrue: [^ self]].
    (result = #cancelled) ifTrue: [^ self].

    self updateLastHistoryEntryIfNeeded.

    fName _ (self nameFromFileName: fName), '.class'.
    projectDirectory _ FileDirectory on: (FileDirectory dirPathFor: fName).
    projectName _ FileDirectory localNameFor: fName.

    projectInfo at: 'author' put: author.
    self updateHistoryProjectName: projectName op: 'save'.
    self writeScratchProject.
! !

!ScratchFrameMorph methodsFor: 'file read/write' stamp: 'BC 3/30/2013 18:15'!
importScratchProject
    "Allow the user to select a project to open, then merge that project's sprites with the
current project."

    | response |
    self closeMediaEditorsAndDialogs ifFalse: [^ self].
    self stopAll.

    response _ ScratchFileChooserDialog
        chooseExistingFileType: #project
        extensions: #(.class)
        title: 'Import Class'.
    response ifNil: [^ self].

    self importSpriteOrProject: response.
! !

I'm pretty sure you're on the wrong page.

It is a patch that allows you to import and export things like classes in the java program.


I am made a mod for Scratch. If you have any ideas for the mod please post it on this forum page.http://scratch.mit.edu/forums/viewtopic.php?id=108265http://internetometer.com/image/38591.png
I am http://blocks.scratchr.org/API.php?action=onlineStatus&type=text&user=machinespray

Offline

 

Board footer