So I have a pretty large string and it will only get bigger. It's currently at 1,539 characters and I expect to tack on a couple more queries to it in the future. So when I first built the string I did it the old fashioned way created around 7 string objects and concatenating them all with the plus.
But then I remembered what my teacher said way back when and decided to switch it up and try the string builder. The only problem is the only real disadvantage I can find online about using this is readability and I don't think the readability is all that bad to be honest.
So my question is is building an object, to house over 1500 characters a good idea or a bad idea. And if you were in my situation would you use string, string builder, or string buffer? And please save the speech on readability. It's just my code and I'm the only one reading it and it's not all that difficult so don't use it as a variable. Thank you!
StringBuilder builder = new StringBuilder(1600);
builder.append("SELECT stride.id AS link, user.userName, user.displayName, user.currentDefault, stride.content, stride.timestamp, stride.recipientView, \"stride\" as notType FROM user INNER JOIN stride ON user.id = stride.sourceUserId WHERE stride.recipientId = ? AND stride.sourceUserId != ? ");
builder.append(" UNION ALL ");
builder.append("SELECT stride.id AS link, user.userName, user.displayName, user.currentDefault, stride.content, strideLike.timestamp, strideLike.recipientView, \"strideLike\" as notType FROM user INNER JOIN strideLike ON strideLike.sourceUserId = user.id INNER JOIN stride ON stride.id = strideLike.strideId WHERE strideLike.recipientId = ? AND user.id != strideLike.recipientId ");
builder.append(" UNION ALL ");
builder.append("SELECT stride.id AS link, user.userName, user.displayName, user.currentDefault, strideComment.content, strideComment.timestamp, strideComment.recipientView, \"strideCommentMe\" as notType FROM user INNER JOIN strideComment ON user.id = strideComment.sourceUserId INNER JOIN stride ON stride.id = strideComment.strideId WHERE stride.sourceUserId = ? AND user.id != stride.sourceUserId ");
builder.append(" UNION ALL ");
builder.append("SELECT stride.id AS link, user.userName, user.displayName, user.currentDefault, strideComment.content, strideCommentLike.timestamp, strideCommentLike.recipientView, \"strideCommentLike\" AS notType FROM user INNER JOIN strideCommentLike ON strideCommentLike.sourceUserId = user.id INNER JOIN strideComment ON strideComment.id = strideCommentLike.commentId INNER JOIN stride ON stride.id = strideComment.strideId WHERE strideComment.sourceUserId = ? AND user.id != ? ");
builder.append(" ORDER BY timestamp DESC");