language-concepts

Why aren't static methods considered good OO practice? [closed]

心不动则不痛 提交于 2019-11-27 07:34:29
I'm reading Programming Scala . At the beginning of chapter 4, the author comments that Java supports static methods, which are "not-so-pure OO concepts." Why is this so? One reason that static methods aren't very OO that hasn't been mentioned so far is that interfaces and abstract classes only define non-static methods. Static methods thus don't fit very well into inheritance. Note also that static methods do not have access to " super ", which means that static methods cannot be overridden in any real sense. Actually, they can't be overridden at all, only hidden. Try this: public class Test

What is the meaning of “dot parenthesis” syntax in Golang?

拟墨画扇 提交于 2019-11-26 09:46:48
问题 I am studying a sample Go application that stores data in mongodb. The code at this line (https://github.com/zeebo/gostbook/blob/master/context.go#L36) seems to access an user ID stored in a gorilla session: if uid, ok := sess.Values[\"user\"].(bson.ObjectId); ok { ... } Would someone please explain to me the syntax here? I understand that sess.Values[\"user\"] gets a value from the session, but what is the part that follows? Why is the expression after the dot in parentheses? Is this a