Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (868)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Aspect Oriented Programming: Has anyone tried it?  (Read 6162 times)
0 Members and 1 Guest are viewing this topic.
Offline actual

JGO Coder


Medals: 25



« Posted 2014-09-08 16:56:58 »

I have recently been taking a look at Aspect Oriented Programming. It seems like an interesting compliment to OOP and I can see some potential uses in game development. Looking at AspectJ it looks like the overhead is all (or mostly?) at compile time with little to no run time overhead.

Has anyone tried AOP programming before and if so what were your impressions?
Offline 65K
« Reply #1 - Posted 2014-09-08 17:14:15 »

A great way to obfuscate software systems.

Lethal Running - a RPG about a deadly game show held in a futuristic dystopian society.
Offline EgonOlsen
« Reply #2 - Posted 2014-09-08 19:43:06 »

It's a solution looking for a problem. We tried it at work, it just complicated stuff. We removed it completely and never looked back.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
Administrator

« JGO Overlord »


Medals: 1371
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2014-09-08 20:04:00 »

Decoupling functionality and stitching it back together with regex/patterns is a great way to ensure job security. I steered clear of this (anti)pattern because it was so obviously nuts. Clicking through code - using your IDE - is invaluable when tracing the flow of your code. AOP scatters your decoupled code around your code base, leaving your IDE and you clueless when debugging. It seems like its finally on the way out though, people are dropping it left and right.

Learn from the mistakes others made, if you don't see the disadvantages right away Smiley

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline basil_

« JGO Bitwise Duke »


Medals: 418
Exp: 13 years



« Reply #4 - Posted 2014-09-08 22:54:39 »

[...] I steered clear of this (anti)pattern because it was so obviously nuts. Clicking through code - using your IDE - is invaluable when tracing the flow of your code.
and then you made LibStruct Wink
Offline Riven
Administrator

« JGO Overlord »


Medals: 1371
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #5 - Posted 2014-09-08 23:09:22 »

I don't see how there is any irony or contradiction there, honestly. Structs don't change flow, they give you control over the memory layout of your data.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline basil_

« JGO Bitwise Duke »


Medals: 418
Exp: 13 years



« Reply #6 - Posted 2014-09-08 23:20:49 »

oh .. i was refering to myself trying to catch the code flow of LibStruct. breakpoints always work, it's just nebulous with the agent in the middle Smiley
Offline actual

JGO Coder


Medals: 25



« Reply #7 - Posted 2014-09-08 23:24:18 »

Points taken. One of the things that piqued my interest in AOP is the ability to possibly consolidate code that might be spread across various classes into a smaller set of aspects. Counter balancing that was the worry about making the same code less comprehensible.
Offline noctarius

JGO Knight


Medals: 61


Manager Developer Relations @Hazelcast


« Reply #8 - Posted 2014-09-09 04:34:47 »

Well it has it's purpose, pretty much limited to profiling and logging Cheesy

Offline Roquen

JGO Kernel


Medals: 518



« Reply #9 - Posted 2014-09-09 10:09:15 »

I've always thought it was a bad direction.  Rewritting rules are useful.  Contracts are useful.  The two of these give you most of aspects.  Toss in knowing how to perform various forms method dispatching and you're done.  Aspects as a debugging tool seems like shoehorning in a use-case.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline noctarius

JGO Knight


Medals: 61


Manager Developer Relations @Hazelcast


« Reply #10 - Posted 2014-09-09 10:22:41 »

Wel AOP in Java is normally mostly used to simulate Traits or Mixins. Maybe a reasonable usecase.

Offline actual

JGO Coder


Medals: 25



« Reply #11 - Posted 2014-09-09 13:05:38 »

A bit long and not the most dynamic speaker but here is a talk attempting dispel some myths about AOP.
Offline princec

« JGO Spiffy Duke »


Medals: 1146
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #12 - Posted 2014-09-09 13:13:29 »

What AOP appears to give me is similar to what the addition of a 3rd dimension to graphics gives me: all sorts of cool possibilities, and massive headaches.

Cas Smiley

Offline Roquen

JGO Kernel


Medals: 518



« Reply #13 - Posted 2014-09-09 14:03:12 »

Wel AOP in Java is normally mostly used to simulate Traits or Mixins. Maybe a reasonable usecase.
That to me?  I've mostly seen pre & post conditions (so contracts).  And I'm covering mixin's by dispatch and composition.  Trait's seems like a really painful thing to mimic with aspects...but then again it all seems kinda painful to me.
Offline princec

« JGO Spiffy Duke »


Medals: 1146
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #14 - Posted 2014-09-09 14:15:20 »

Contracts would most likely be far more useful to more people than the whole mess that AOP seems to be.

Still haven't quite come up with a decent use case beyond injecting logging either. Stuff like transaction handling is critical to functionality and logic and I seriously wouldn't want to leave it in the hands of a bit of code miles away which I had no idea was even executing... whereas logging isn't.

What might have been nice in Java is a way to annotated how extension points in abstract classes were meant to be used. I find myself using this pattern a lot:
1  
2  
3  
4  
public final void tick() {
   doTick();
}
protected abstract void doTick();

or this:
1  
2  
3  
4  
5  
6  
public final void tick() {
   doTick();
}
protected void doTick() {
   // By default, do nothing special
}

with the expectation that the derived class implements doTick(). However what is the rule for a further derived class? I end up with having to remember to do this:
1  
2  
3  
4  
5  
@Override
protected void doTick() {
   super.doTick(); // Don't forget to do this FIRST or everything breaks!
   // blah
}

or this:
1  
2  
3  
4  
5  
@Override
protected void doTick() {
   // blah
   super.doTick(); // Don't forget to do this LAST or everything breaks!
}

or even this:
1  
2  
3  
4  
5  
protected final void doTick() {
   // blah
   doTickMoreStuff();
}
protected abstract void doTickMoreStuff() {


... and so on. Some keywords or annotations to help enforce the accepted method of extension would solve a lot of that.

I digress. Back to work. In C#. Gah.

Cas Smiley

Pages: [1]
  ignore  |  Print  
 
 

 
Riven (581 views)
2019-09-04 15:33:17

hadezbladez (5510 views)
2018-11-16 13:46:03

hadezbladez (2402 views)
2018-11-16 13:41:33

hadezbladez (5772 views)
2018-11-16 13:35:35

hadezbladez (1223 views)
2018-11-16 13:32:03

EgonOlsen (4661 views)
2018-06-10 19:43:48

EgonOlsen (5682 views)
2018-06-10 19:43:44

EgonOlsen (3198 views)
2018-06-10 19:43:20

DesertCoockie (4095 views)
2018-05-13 18:23:11

nelsongames (5115 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!