How to reverse a string
-
In the eighties, the "dude, OO is soooo easy" decade string s2 = reverse(s1); In the nineties, the "dude, this cannot be THIS easy" decade string s2 = s1.Clone(); s2.Reverse(); In the current, "best practices and patterns" decade StringClonator clonator = new StringClonator(); string s2 = clonator.Clone(s1); StringIterator begin = s2.Begin(); StringIterator end = s2.End(); StringBuffer buffer = new StringBuffer(s2.size()); ReversingStrategy reverser = ReversingStrategyFactory.GetInstance.NewReversingStrategy(); reverser.Reverse(s2, begin, end, buffer); s2.AssignBuffer(buffer.InnerBuffer());
-
In the eighties, the "dude, OO is soooo easy" decade string s2 = reverse(s1); In the nineties, the "dude, this cannot be THIS easy" decade string s2 = s1.Clone(); s2.Reverse(); In the current, "best practices and patterns" decade StringClonator clonator = new StringClonator(); string s2 = clonator.Clone(s1); StringIterator begin = s2.Begin(); StringIterator end = s2.End(); StringBuffer buffer = new StringBuffer(s2.size()); ReversingStrategy reverser = ReversingStrategyFactory.GetInstance.NewReversingStrategy(); reverser.Reverse(s2, begin, end, buffer); s2.AssignBuffer(buffer.InnerBuffer());
ROTFL !!! Is this Java ?
Christian Graus Driven to the arms of OSX by Vista. "Iam doing the browsing center project in vb.net using c# coding" - this is why I don't answer questions much anymore. Oh, and Microsoft doesn't want me to.
-
In the eighties, the "dude, OO is soooo easy" decade string s2 = reverse(s1); In the nineties, the "dude, this cannot be THIS easy" decade string s2 = s1.Clone(); s2.Reverse(); In the current, "best practices and patterns" decade StringClonator clonator = new StringClonator(); string s2 = clonator.Clone(s1); StringIterator begin = s2.Begin(); StringIterator end = s2.End(); StringBuffer buffer = new StringBuffer(s2.size()); ReversingStrategy reverser = ReversingStrategyFactory.GetInstance.NewReversingStrategy(); reverser.Reverse(s2, begin, end, buffer); s2.AssignBuffer(buffer.InnerBuffer());
interface Printer {
void print(Message message);
}class Message {
private String message;public Message(String message) { this.message = message; } public void print(Printer printer) { printer.print(this); } public String toString() { return message; }
}
abstract class AbstractPrinterFactory {
public static AbstractPrinterFactory getFactory() {
return new SystemOutPrinterFactory();
}public abstract Printer getPrinter();
}
class SystemOutPrinterFactory extends AbstractPrinterFactory {
public Printer getPrinter() {
return new SystemOutPrinter();
}
}class SystemOutPrinter implements Printer {
public void print(Message message) {
System.out.println(message);
}
}class HelloWorld {
public static void main(String[] args) {
Message message = new Message("Hello, World!");
AbstractPrinterFactory factory = AbstractPrinterFactory.getFactory();
Printer printer = factory.getPrinter();
message.print(printer);
}
} -
In the eighties, the "dude, OO is soooo easy" decade string s2 = reverse(s1); In the nineties, the "dude, this cannot be THIS easy" decade string s2 = s1.Clone(); s2.Reverse(); In the current, "best practices and patterns" decade StringClonator clonator = new StringClonator(); string s2 = clonator.Clone(s1); StringIterator begin = s2.Begin(); StringIterator end = s2.End(); StringBuffer buffer = new StringBuffer(s2.size()); ReversingStrategy reverser = ReversingStrategyFactory.GetInstance.NewReversingStrategy(); reverser.Reverse(s2, begin, end, buffer); s2.AssignBuffer(buffer.InnerBuffer());
LMAO.
Sathesh. Blessed is the season which engages the whole world in a conspiracy of love.
-
In the eighties, the "dude, OO is soooo easy" decade string s2 = reverse(s1); In the nineties, the "dude, this cannot be THIS easy" decade string s2 = s1.Clone(); s2.Reverse(); In the current, "best practices and patterns" decade StringClonator clonator = new StringClonator(); string s2 = clonator.Clone(s1); StringIterator begin = s2.Begin(); StringIterator end = s2.End(); StringBuffer buffer = new StringBuffer(s2.size()); ReversingStrategy reverser = ReversingStrategyFactory.GetInstance.NewReversingStrategy(); reverser.Reverse(s2, begin, end, buffer); s2.AssignBuffer(buffer.InnerBuffer());
:laugh: :laugh: Very funny. Have you seen this rant about frameworks[^]. It's a similar thing. Old, but funny.
Simon
-
In the eighties, the "dude, OO is soooo easy" decade string s2 = reverse(s1); In the nineties, the "dude, this cannot be THIS easy" decade string s2 = s1.Clone(); s2.Reverse(); In the current, "best practices and patterns" decade StringClonator clonator = new StringClonator(); string s2 = clonator.Clone(s1); StringIterator begin = s2.Begin(); StringIterator end = s2.End(); StringBuffer buffer = new StringBuffer(s2.size()); ReversingStrategy reverser = ReversingStrategyFactory.GetInstance.NewReversingStrategy(); reverser.Reverse(s2, begin, end, buffer); s2.AssignBuffer(buffer.InnerBuffer());
:) I suspect if you include the unit tests, it could be even more verbose.
MrPlankton
(bad guy)"Fear is a hammer, and when the people are beaten finally to the conviction that their existence hangs by a frayed thread, they will be led where they need to go."
(good guy)"Which is where?"
(bad guy)"To a responsible future in a properly managed world."
Dean Koontz, The Good Guy -
In the eighties, the "dude, OO is soooo easy" decade string s2 = reverse(s1); In the nineties, the "dude, this cannot be THIS easy" decade string s2 = s1.Clone(); s2.Reverse(); In the current, "best practices and patterns" decade StringClonator clonator = new StringClonator(); string s2 = clonator.Clone(s1); StringIterator begin = s2.Begin(); StringIterator end = s2.End(); StringBuffer buffer = new StringBuffer(s2.size()); ReversingStrategy reverser = ReversingStrategyFactory.GetInstance.NewReversingStrategy(); reverser.Reverse(s2, begin, end, buffer); s2.AssignBuffer(buffer.InnerBuffer());
How about the "Dude, I can do that in one line of supported illegal C" #define swap(x, y) x^= y^= x^=y
I've heard more said about less.
-
How about the "Dude, I can do that in one line of supported illegal C" #define swap(x, y) x^= y^= x^=y
I've heard more said about less.
nope, your sample is "1337 codez", my sample is "enterprise-ready code"
-
nope, your sample is "1337 codez", my sample is "enterprise-ready code"
Oh yeah. Did you work in the enterprise in the late 80s early 90s? I saw this swap everywhere and had to actually prove to a guy that it is in fact illegal in C++. Can't assign twice to a variable between two sequence points. Definitely in the enterprise.
I've heard more said about less.