Creation of personal tools

Recently, I have been thinking about creating a kind of "toolkit" for myself in Java. It will consist of standard algorithms and data structures that are often used, but a pain for implementation. (I think graphs, trees, etc.)

What would be the best way to do this? I was thinking about using generics or using an abstract class. That way, I could have any object that would like to use methods, just provide the getGraphData () method or something like that.

I think generics can be better, although due to the fact that the abstract class will force me to inherit it, which can become problematic.

+3
source share
3 answers

...

Java. , , , , Google Collections. , .

+3

:

1:

  • Graph
  • Graph, .

2:

  • Graph ( )
  • .

, , STL . . , algos, , / ..

JRH.

0

, , , - .

, - , , - , Java Google. , (List, Map ..) .

Then, if it is for educational purposes, continue and write your own implementations. It should be fun, interesting and definitely challenging. Try to check if the behavior is consistent - write tests to make sure of typical use and cases with edges.

However, I would recommend not using it for real use other than educational use. You should not make mistakes while studying, but this is a completely different story, once in the real world.

0
source

Source: https://habr.com/ru/post/1710681/


All Articles